Skip to content

Commit

Permalink
feat: allow specifying proxy when creating project
Browse files Browse the repository at this point in the history
close #1009
  • Loading branch information
yyx990803 committed Apr 27, 2018
1 parent be3bede commit b1512be
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/@vue/cli/bin/vue.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ program
.option('-g, --git [message]', 'Force / skip git intialization, optionally specify initial commit message')
.option('-f, --force', 'Overwrite target directory if it exists')
.option('-c, --clone', 'Use git clone when fetching remote preset')
.option('-x, --proxy', 'Use specified proxy when creating project')
.action((name, cmd) => {
require('../lib/create')(name, cleanArgs(cmd))
})
Expand Down
6 changes: 5 additions & 1 deletion packages/@vue/cli/lib/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,14 @@ const { error, stopSpinner } = require('@vue/cli-shared-utils')
const validateProjectName = require('validate-npm-package-name')

async function create (projectName, options) {
if (options.proxy) {
process.env.HTTP_PROXY = options.proxy
}

const inCurrent = projectName === '.'
const name = inCurrent ? path.relative('../', process.cwd()) : projectName
const targetDir = path.resolve(projectName || '.')

const result = validateProjectName(name)
if (!result.validForNewPackages) {
console.error(chalk.red(`Invalid project name: "${projectName}"`))
Expand Down

0 comments on commit b1512be

Please sign in to comment.