Skip to content

Commit

Permalink
small refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Dec 29, 2017
1 parent b67f9bc commit b7223aa
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 18 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ cd packages/@vue/cli
yarn link

# create test projects in /packages/test
export VUE_CLI_DEBUG=true
export VUE_CLI_DEBUG=true # necessary for local tests to work
cd -
cd packages/test
vue create test-app
Expand Down
18 changes: 1 addition & 17 deletions packages/@vue/cli/lib/Creator.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const installDeps = require('./util/installDeps')
const PromptModuleAPI = require('./PromptModuleAPI')
const writeFileTree = require('./util/writeFileTree')
const { logWithSpinner, stopSpinner } = require('./util/spinner')
const updatePackageForDev = require('./util/updatePackageForDev')

const {
error,
Expand Down Expand Up @@ -230,20 +231,3 @@ module.exports = class Creator {
}
}
}

function updatePackageForDev (targetDir, deps) {
const pkg = require(path.resolve(targetDir, 'package.json'))
pkg.devDependencies = {}
deps.forEach(dep => {
pkg.devDependencies[dep] = require(path.resolve(
__dirname,
'../../../',
dep,
'package.json'
)).version
})
fs.writeFileSync(
path.resolve(targetDir, 'package.json'),
JSON.stringify(pkg, null, 2)
)
}
21 changes: 21 additions & 0 deletions packages/@vue/cli/lib/util/updatePackageForDev.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// dev only

const fs = require('fs')
const path = require('path')

module.exports = function updatePackageForDev (targetDir, deps) {
const pkg = require(path.resolve(targetDir, 'package.json'))
pkg.devDependencies = {}
deps.forEach(dep => {
pkg.devDependencies[dep] = require(path.resolve(
__dirname,
'../../../',
dep,
'package.json'
)).version
})
fs.writeFileSync(
path.resolve(targetDir, 'package.json'),
JSON.stringify(pkg, null, 2)
)
}

0 comments on commit b7223aa

Please sign in to comment.