Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
]
if (answers.packageManager) args.push('--packageManager', answers.packageManager)
if (answers.registryUrl) args.push('--registry', answers.registryUrl)
if (answers.proxy) args.push('--proxy', answers.proxy)
if (answers.bare) args.push('--bare')
if (answers.force) args.push('--force')
// Git
if (!answers.useGit) {
args.push('--no-git')
} else if (answers.commitMessage) {
args.push('--git', answers.commitMessage)
}
// Preset
args.push('--inlinePreset', JSON.stringify(preset))
const cmd = execa('vue', [
'create',
answers.projectName,
...args
], {
cwd,
stdio: ['inherit', 'pipe', 'inherit']
})
const onData = buffer => {
const text = buffer.toString().trim()
if (text) {
setProgress({
info: text
})
addLog({
type: 'info',
const args = minimist(process.argv, {
alias: {
r: 'registry'
}
})
if (args.registry) {
this._registry = args.registry
} else if (await shouldUseTaobao(this.bin)) {
this._registry = registries.taobao
} else {
try {
this._registry = (await execa(this.bin, ['config', 'get', 'registry'])).stdout
} catch (e) {
// Yarn 2 uses `npmRegistryServer` instead of `registry`
this._registry = (await execa(this.bin, ['config', 'get', 'npmRegistryServer'])).stdout
}
}
return this._registry
}
addLog({
taskId: task.id,
type: 'stdout',
text: chalk.grey(`$ ${command} ${args.join(' ')}`)
}, context)
task.time = Date.now()
// Task env
process.env.VUE_CLI_CONTEXT = cwd.get()
process.env.VUE_CLI_PROJECT_ID = projects.getCurrent(context).id
const nodeEnv = process.env.NODE_ENV
delete process.env.NODE_ENV
const child = execa(command, args, {
cwd: cwd.get(),
stdio: ['inherit', 'pipe', 'pipe'],
shell: true
})
if (typeof nodeEnv !== 'undefined') {
process.env.NODE_ENV = nodeEnv
}
task.child = child
const outPipe = logPipe(queue => {
addLog({
taskId: task.id,
type: 'stdout',
text: queue
async getMetadata (packageName, { field = '' } = {}) {
const registry = await this.getRegistry()
const metadataKey = `${this.bin}-${registry}-${packageName}`
let metadata = metadataCache.get(metadataKey)
if (metadata) {
return metadata
}
const args = await this.addRegistryToArgs(['info', packageName, field, '--json'])
const { stdout } = await execa(this.bin, args)
metadata = JSON.parse(stdout)
if (this.bin === 'yarn') {
// `yarn info` outputs messages in the form of `{"type": "inspect", data: {}}`
metadata = metadata.data
}
metadataCache.set(metadataKey, metadata)
return metadata
}
async function getRoot (context) {
if (!hasProjectGit(cwd.get())) return cwd.get()
const { stdout } = await execa('git', [
'rev-parse',
'--show-toplevel'
], {
cwd: cwd.get()
})
return stdout
}
}
if (args['with-selenium']) {
process.env.VUE_NIGHTWATCH_USE_SELENIUM = '1'
}
if (args.headless) {
process.env.VUE_NIGHTWATCH_HEADLESS = '1'
}
if (args.parallel) {
process.env.VUE_NIGHTWATCH_CONCURRENT = '1'
}
const nightWatchBinPath = require.resolve('nightwatch/bin/nightwatch')
const runner = execa(nightWatchBinPath, rawArgs, { stdio: 'inherit' })
if (server) {
runner.on('exit', () => server.close())
runner.on('error', () => server.close())
}
if (process.env.VUE_CLI_TEST) {
runner.on('exit', code => {
process.exit(code)
})
}
return runner
})
})
async function commit (message, context) {
if (!hasProjectGit(cwd.get())) return false
await execa('git', ['add', '*'], {
cwd: cwd.get()
})
await execa('git', ['commit', '-m', message.replace(/"/, '\\"')], {
cwd: cwd.get()
})
return true
}
if (afterInvokeCbs.length || afterAnyInvokeCbs.length) {
logWithSpinner('⚓', `Running completion hooks...`)
for (const cb of afterInvokeCbs) {
await cb()
}
for (const cb of afterAnyInvokeCbs) {
await cb()
}
stopSpinner()
log()
}
log(`${chalk.green('✔')} Successfully invoked generator for plugin: ${chalk.cyan(plugin.id)}`)
if (!process.env.VUE_CLI_TEST && hasProjectGit(context)) {
const { stdout } = await execa('git', [
'ls-files',
'--exclude-standard',
'--modified',
'--others'
], {
cwd: context
})
if (stdout.trim()) {
log(` The following files have been updated / added:\n`)
log(
chalk.red(
stdout
.split(/\r?\n/g)
.map(line => ` ${line}`)
.join('\n')
)
async function getInstallationCommand () {
if (hasYarn()) {
const { stdout: yarnGlobalDir } = await execa('yarn', ['global', 'dir'])
if (__dirname.includes(yarnGlobalDir)) {
return 'yarn global add'
}
}
if (hasPnpm3OrLater()) {
const { stdout: pnpmGlobalPrefix } = await execa('pnpm', ['config', 'get', 'prefix'])
if (__dirname.includes(pnpmGlobalPrefix) && __dirname.includes('pnpm-global')) {
return `pnpm i -g`
}
}
const { stdout: npmGlobalPrefix } = await execa('npm', ['config', 'get', 'prefix'])
if (__dirname.includes(npmGlobalPrefix)) {
return `npm i -g`
}