@@ -10,12 +10,13 @@ const async = require('async')
10
10
const extend = Object . assign || require ( 'util' ) . _extend
11
11
const generate = require ( '../../lib/generate' )
12
12
const metadata = require ( '../../lib/options' )
13
+ const { isLocalPath, getTemplatePath } = require ( '../../lib/local-path' )
13
14
14
- const MOCK_META_JSON_PATH = './test/e2e/mock-meta-json'
15
- const MOCK_TEMPLATE_REPO_PATH = './test/e2e/mock-template-repo'
15
+ const MOCK_META_JSON_PATH = path . resolve ( './test/e2e/mock-meta-json' )
16
+ const MOCK_TEMPLATE_REPO_PATH = path . resolve ( './test/e2e/mock-template-repo' )
16
17
const MOCK_TEMPLATE_BUILD_PATH = path . resolve ( './test/e2e/mock-template-build' )
17
- const MOCK_METADATA_REPO_JS_PATH = './test/e2e/mock-metadata-repo-js'
18
- const MOCK_SKIP_GLOB = './test/e2e/mock-skip-glob'
18
+ const MOCK_METADATA_REPO_JS_PATH = path . resolve ( './test/e2e/mock-metadata-repo-js' )
19
+ const MOCK_SKIP_GLOB = path . resolve ( './test/e2e/mock-skip-glob' )
19
20
20
21
function monkeyPatchInquirer ( answers ) {
21
22
// monkey patch inquirer
@@ -67,16 +68,16 @@ describe('vue-cli', () => {
67
68
} )
68
69
} )
69
70
70
- it ( 'adds additional data to meta data' , ( ) => {
71
- const data = generate ( 'test' , MOCK_META_JSON_PATH , MOCK_TEMPLATE_BUILD_PATH )
71
+ it ( 'adds additional data to meta data' , done => {
72
+ const data = generate ( 'test' , MOCK_META_JSON_PATH , MOCK_TEMPLATE_BUILD_PATH , done )
72
73
expect ( data . destDirName ) . to . equal ( 'test' )
73
74
expect ( data . inPlace ) . to . equal ( false )
74
75
} )
75
76
76
- it ( 'sets `inPlace` to true when generating in same directory' , ( ) => {
77
+ it ( 'sets `inPlace` to true when generating in same directory' , done => {
77
78
const currentDir = process . cwd ( )
78
79
process . chdir ( MOCK_TEMPLATE_BUILD_PATH )
79
- const data = generate ( 'test' , MOCK_META_JSON_PATH , MOCK_TEMPLATE_BUILD_PATH )
80
+ const data = generate ( 'test' , MOCK_META_JSON_PATH , MOCK_TEMPLATE_BUILD_PATH , done )
80
81
expect ( data . destDirName ) . to . equal ( 'test' )
81
82
expect ( data . inPlace ) . to . equal ( true )
82
83
process . chdir ( currentDir )
@@ -199,4 +200,27 @@ describe('vue-cli', () => {
199
200
done ( )
200
201
} )
201
202
} )
203
+
204
+ it ( 'checks for local path' , ( ) => {
205
+ expect ( isLocalPath ( '../' ) ) . to . equal ( true )
206
+ expect ( isLocalPath ( '../../' ) ) . to . equal ( true )
207
+ expect ( isLocalPath ( '../template' ) ) . to . equal ( true )
208
+ expect ( isLocalPath ( '../template/abc' ) ) . to . equal ( true )
209
+ expect ( isLocalPath ( './' ) ) . to . equal ( true )
210
+ expect ( isLocalPath ( '.' ) ) . to . equal ( true )
211
+ expect ( isLocalPath ( 'c:/' ) ) . to . equal ( true )
212
+ expect ( isLocalPath ( 'D:/' ) ) . to . equal ( true )
213
+
214
+ expect ( isLocalPath ( 'webpack' ) ) . to . equal ( false )
215
+ expect ( isLocalPath ( 'username/rep' ) ) . to . equal ( false )
216
+ expect ( isLocalPath ( 'bitbucket:username/rep' ) ) . to . equal ( false )
217
+ } )
218
+
219
+ it ( 'normalizes template path' , ( ) => {
220
+ expect ( getTemplatePath ( '/' ) ) . to . equal ( '/' )
221
+ expect ( getTemplatePath ( '/absolute/path' ) ) . to . equal ( '/absolute/path' )
222
+
223
+ expect ( getTemplatePath ( '..' ) ) . to . equal ( path . join ( __dirname , '/../../..' ) )
224
+ expect ( getTemplatePath ( '../template' ) ) . to . equal ( path . join ( __dirname , '/../../../template' ) )
225
+ } )
202
226
} )
0 commit comments