How to use the @vue/cli-shared-utils.execa function in @vue/cli-shared-utils

To help you get started, we’ve selected a few @vue/cli-shared-utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github vuejs / vue-cli / packages / @vue / cli-guijs-plugin / lib / create-project.js View on Github external
]
  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',
github vuejs / vue-cli / packages / @vue / cli / lib / util / ProjectPackageManager.js View on Github external
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
  }
github vuejs / vue-cli / packages / @vue / cli-ui / apollo-server / connectors / tasks.js View on Github external
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
github vuejs / vue-cli / packages / @vue / cli / lib / util / ProjectPackageManager.js View on Github external
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
  }
github vuejs / vue-cli / packages / @vue / cli-ui / apollo-server / connectors / git.js View on Github external
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
}
github vuejs / vue-cli / packages / @vue / cli-plugin-e2e-nightwatch / index.js View on Github external
}

      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
    })
  })
github vuejs / vue-cli / packages / @vue / cli-ui / apollo-server / connectors / git.js View on Github external
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
}
github vuejs / vue-cli / packages / @vue / cli / lib / invoke.js View on Github external
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')
        )
github vuejs / vue-cli / packages / @vue / cli / lib / util / clearConsole.js View on Github external
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`
  }