How to use the @vue/cli-shared-utils.hasProjectGit 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 KuangPF / vue-cli-analysis / packages / @vue / cli / lib / invoke.js View on Github external
loadOptions().packageManager || (hasProjectYarn(context) ? 'yarn' : 'npm')
    await installDeps(context, packageManager, plugin.options && plugin.options.registry)
  }

  if (createCompleteCbs.length) {
    logWithSpinner('⚓', `Running completion hooks...`)
    for (const cb of createCompleteCbs) {
      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 KuangPF / vue-cli-analysis / packages / @vue / cli / lib / Creator.js View on Github external
async shouldInitGit (cliOptions) {
    if (!hasGit()) {
      return false
    }
    // --git
    if (cliOptions.forceGit) {
      return true
    }
    // --no-git
    if (cliOptions.git === false || cliOptions.git === 'false') {
      return false
    }
    // default: true unless already in a git repo
    return !hasProjectGit(this.context)
  }
}
github vuejs / vue-cli / packages / @vue / cli / lib / Creator.js View on Github external
shouldInitGit (cliOptions) {
    if (!hasGit()) {
      return false
    }
    // --git
    if (cliOptions.forceGit) {
      return true
    }
    // --no-git
    if (cliOptions.git === false || cliOptions.git === 'false') {
      return false
    }
    // default: true unless already in a git repo
    return !hasProjectGit(this.context)
  }
}
github vuejs / vue-cli / packages / @vue / cli / lib / util / confirmIfGitDirty.js View on Github external
module.exports = async function confirmIfGitDirty (context) {
  if (process.env.VUE_CLI_SKIP_DIRTY_GIT_PROMPT || process.env.VUE_CLI_API_MODE) {
    return true
  }

  process.env.VUE_CLI_SKIP_DIRTY_GIT_PROMPT = true

  if (!hasProjectGit(context)) {
    return true
  }

  const { stdout } = await execa('git', ['status', '--porcelain'], { cwd: context })
  if (!stdout) {
    return true
  }

  warn(`There are uncommited changes in the current repository, it's recommended to commit or stash them first.`)
  const { ok } = await inquirer.prompt([
    {
      name: 'ok',
      type: 'confirm',
      message: 'Still proceed?',
      default: false
    }
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-ui / apollo-server / connectors / git.js View on Github external
async function reset (context) {
  if (!hasProjectGit(cwd.get())) return false

  await execa('git', ['reset'], {
    cwd: cwd.get()
  })
  return true
}
github vuejs / vue-cli / packages / @vue / cli / lib / Upgrader.js View on Github external
log(`📦  Installing additional dependencies...`)
      log()
      await this.pm.install()
    }

    if (createCompleteCbs.length) {
      logWithSpinner('⚓', `Running completion hooks...`)
      for (const cb of createCompleteCbs) {
        await cb()
      }
      stopSpinner()
      log()
    }

    log(`${chalk.green('✔')}  Successfully invoked migrator for plugin: ${chalk.cyan(plugin.id)}`)
    if (!process.env.VUE_CLI_TEST && hasProjectGit(this.context)) {
      const { stdout } = await execa('git', [
        'ls-files',
        '--exclude-standard',
        '--modified',
        '--others'
      ], {
        cwd: this.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-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
}