From e502e462673b3f298f434c71d9ae625748bb1b7f Mon Sep 17 00:00:00 2001 From: Evan You Date: Tue, 15 Nov 2016 22:11:13 -0500 Subject: [PATCH] only look for local templates if path starts with . or / (fix #240) --- bin/vue-init | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/bin/vue-init b/bin/vue-init index 429e717ed3..7b541bff45 100755 --- a/bin/vue-init +++ b/bin/vue-init @@ -64,7 +64,6 @@ process.on('exit', function () { var template = program.args[0] var hasSlash = template.indexOf('/') > -1 var rawName = program.args[1] -var templatePath = exists(template) ? template : path.normalize(path.join(process.cwd(), template)) var inPlace = !rawName || rawName === '.' var name = inPlace ? path.relative('../', process.cwd()) : rawName var to = path.resolve(rawName || '.') @@ -92,12 +91,19 @@ if (exists(to)) { function run () { // check if template is local - if (exists(templatePath)) { - generate(name, templatePath, to, function (err) { - if (err) logger.fatal(err) - console.log() - logger.success('Generated "%s".', name) - }) + if (/^[./]/.test(template)) { + var templatePath = template.charAt(0) === '/' + ? template + : path.normalize(path.join(process.cwd(), template)) + if (exists(templatePath)) { + generate(name, templatePath, to, function (err) { + if (err) logger.fatal(err) + console.log() + logger.success('Generated "%s".', name) + }) + } else { + logger.fatal('Local template "%s" not found.', template) + } } else { checkVersion(function () { if (!hasSlash) {