8000 only look for local templates if path starts with . or / (fix #240) · rashuo/vue-cli@e502e46 · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e502e46

Browse files
committed
only look for local templates if path starts with . or / (fix vuejs#240)
1 parent 8b41f67 commit e502e46

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

8000 ‎bin/vue-init

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ process.on('exit', function () {
6464
var template = program.args[0]
6565
var hasSlash = template.indexOf('/') > -1
6666
var rawName = program.args[1]
67-
var templatePath = exists(template) ? template : path.normalize(path.join(process.cwd(), template))
6867
var inPlace = !rawName || rawName === '.'
6968
var name = inPlace ? path.relative('../', process.cwd()) : rawName
7069
var to = path.resolve(rawName || '.')
@@ -92,12 +91,19 @@ if (exists(to)) {
9291

9392
function run () {
9493
// check if template is local
95-
if (exists(templatePath)) {
96-
generate(name, templatePath, to, function (err) {
97-
if (err) logger.fatal(err)
98-
console.log()
99-
logger.success('Generated "%s".', name)
100-
})
94+
if (/^[./]/.test(template)) {
95+
var templatePath = template.charAt(0) === '/'
96+
? template
97+
: path.normalize(path.join(process.cwd(), template))
98+
if (exists(templatePath)) {
99+
generate(name, templatePath, to, function (err) {
100+
if (err) logger.fatal(err)
101+
console.log()
102+
logger.success('Generated "%s".', name)
103+
})
104+
} else {
105+
logger.fatal('Local template "%s" not found.', template)
106+
}
101107
} else {
102108
checkVersion(function () {
103109
if (!hasSlash) {

0 commit comments

Comments
 (0)
0