Skip to content

Commit 9c4e6b4

Browse files
zigomiryyx990803
authored andcommitted
Wrong directory name (vuejs#87)
* eslint fixes * Override project name with destination directory name. * More explicit name.
1 parent 1eea85e commit 9c4e6b4

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

.eslintrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
{
22
"extends": "standard",
3+
"env": {
4+
"mocha": true,
5+
"node": true
6+
},
37
"rules": {
48
"arrow-parens": [2, "as-needed"]
59
}

lib/generate.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ var path = require('path')
66
var getOptions = require('./options')
77
var ask = require('./ask')
88
var filter = require('./filter')
9+
var extend = Object.assign || require('util')._extend
910

1011
// register hendlebars helper
1112
Handlebars.registerHelper('if_eq', function (a, b, opts) {
@@ -32,7 +33,8 @@ Handlebars.registerHelper('unless_eq', function (a, b, opts) {
3233
module.exports = function generate (name, src, dest, done) {
3334
var opts = getOptions(name, src)
3435
var metalsmith = Metalsmith(path.join(src, 'template'))
35-
var data = metalsmith.metadata()
36+
// extract all gathered data from user and override project name with destination directory name
37+
var data = extend({}, metalsmith.metadata(), { destDirName: name })
3638
// avoid handlebars escaping HTML
3739
data.noEscape = true
3840
metalsmith

test/e2e/test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const generate = require('../../lib/generate')
1313
const MOCK_TEMPLATE_REPO_PATH = './test/e2e/mock-template-repo'
1414
const MOCK_TEMPLATE_BUILD_PATH = path.resolve('./test/e2e/mock-template-build')
1515

16-
function monkeyPatchInquirer(answers) {
16+
function monkeyPatchInquirer (answers) {
1717
// monkey patch inquirer
1818
inquirer.prompt = (questions, cb) => {
1919
const key = questions[0].name
@@ -25,7 +25,7 @@ function monkeyPatchInquirer(answers) {
2525
}
2626
_answers[key] = answers[key]
2727
cb(_answers)
28-
};
28+
}
2929
}
3030

3131
describe('vue-cli', () => {
@@ -95,7 +95,7 @@ describe('vue-cli', () => {
9595
var invalidName = extend({}, answers, {name: 'INVALID-NAME'})
9696
monkeyPatchInquirer(invalidName)
9797
generate('INVALID-NAME', MOCK_TEMPLATE_REPO_PATH, MOCK_TEMPLATE_BUILD_PATH, err => {
98-
expect(err).to.be.an('error');
98+
expect(err).to.be.an('error')
9999
done()
100100
})
101101
})

0 commit comments

Comments
 (0)