internals/setup.js
/**
 * Ask user for new origin for this repository. If provided, call git remote add origin
 * @returns {Promise<any>}
 */
Ask user for new origin for this repository. If provided, call git remote add origin
@returns {Promise}
Ask user for new origin for this repository . If provided call git remote add origin @returns { Promise }
async function askUserForNewRemote() {
  const NEW_REMOTE = 'NEW_REMOTE'
  const answers = await inquirer.prompt([
    {
      type: 'input',
      message:
        'Enter new remote origin (ex: https://github.com/user/my-repo.git) for this repository [Enter to cancel]:  ',
      name: NEW_REMOTE
    }
  ])
  const origin = answers[NEW_REMOTE]
  if (origin) {
    const spinner = ora('Adding new remote to repository').start()
    try {
      await exec(`git remote add origin ${origin}`)
      spinner.succeed(
        'New remote added, run `git push` to send initial commit to remote repository.'
      )
      return true
    } catch (error) {
      spinner.fail(`Add remote failed\n${error}`)
      return false
    }
  } else {
    process.stdout.write(
      'No remote added, run git remote add origin <url> to add one'
    )
    return false
  }
}
async function askUserForNewRemote ( ) { const NEW_REMOTE = 'NEW_REMOTE' const answers = await inquirer . prompt ( [ { type : 'input' , message : 'Enter new remote origin (ex: https://github.com/user/my-repo.git) for this repository [Enter to cancel]:  ' , name : NEW_REMOTE } ] ) const origin = answers [ NEW_REMOTE ] if ( origin ) { const spinner = ora ( 'Adding new remote to repository' ) . start ( ) try { await exec ( ` ${ origin } ` ) spinner . succeed ( 'New remote added, run `git push` to send initial commit to remote repository.' ) return true } catch ( error ) { spinner . fail ( ` \n ${ error } ` ) return false } } else { process . stdout . write ( 'No remote added, run git remote add origin <url> to add one' ) return false } }
Ask user for new origin for this repository.
Ask user for new origin for this repository .