Skip to content

Commit 2e4ea85

Browse files
zigomiryyx990803
authored andcommitted
Support for official templates to specify specific branch. (vuejs#145)
Otherwise it would fail inside checkDistBranch function which expects body to be an array. Also fix linters and test.
1 parent cac2857 commit 2e4ea85

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

bin/vue-init

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,11 @@ function run () {
101101
if (!hasSlash) {
102102
// use official templates
103103
template = 'vuejs-templates/' + template
104-
checkDistBranch(template, downloadAndGenerate)
104+
if (template.indexOf('#') !== -1) {
105+
downloadAndGenerate(template)
106+
} else {
107+
checkDistBranch(template, downloadAndGenerate)
108+
}
105109
} else {
106110
downloadAndGenerate(template)
107111
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"main": "lib/index.js",
2525
"scripts": {
2626
"test": "npm run lint && npm run e2e",
27-
"lint": "eslint test/test.js lib bin/* --env mocha",
27+
"lint": "eslint test/e2e/test.js lib bin/* --env mocha",
2828
"e2e": "rimraf test/e2e/mock-template-build/*.* && cross-env BABEL_ENV=development mocha test/e2e/test.js --slow 1000 --compilers js:babel-core/register"
2929
},
3030
"dependencies": {

test/e2e/test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,15 @@ describe('vue-cli', () => {
5050
})
5151

5252
it('read metadata from js', done => {
53-
const meta = metadata('test-pkg', __dirname + '/mock-metadata-repo-js')
53+
const meta = metadata('test-pkg', path.join(__dirname, '/mock-metadata-repo-js'))
5454
expect(meta).to.be.an('object')
5555
expect(meta.prompts).to.have.property('description')
5656
done()
5757
})
5858

5959
it('helpers', done => {
6060
monkeyPatchInquirer(answers)
61-
const buildPath = __dirname + '/mock-metadata-repo-js'
61+
const buildPath = path.join(__dirname, '/mock-metadata-repo-js')
6262
generate('test', buildPath, MOCK_TEMPLATE_BUILD_PATH, err => {
6363
if (err) done(err)
6464
const contents = fs.readFileSync(`${MOCK_TEMPLATE_BUILD_PATH}/readme.md`, 'utf-8')

0 commit comments

Comments
 (0)