Skip to content

Commit

Permalink
add --yarn flag and use npm by default
Browse files Browse the repository at this point in the history
  • Loading branch information
ruddell committed Jul 24, 2019
1 parent ed639f8 commit 66ee637
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
3 changes: 2 additions & 1 deletion docs/advanced-usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ You can pass flags for each of the options.
| Flag | Possible Values | Action |
| ------------------------ | ------------------------------ | ---------------------------------------------- |
| `--jh-dir` | backend, ../backend | The JHipster app's directory |
| `--detox` | true, false | Enables Detox E2E tests |
| `--detox` | true, false | Enables Detox E2E tests |
| `--skip-git` | | Skips git init |
| `--skip-lint` | | Skips `standard` initialization (linting) |
| `--react-native-version` | 0.60.0 | Install specific React Native version |
| `--yarn ` | | Uses yarn in place of npm when generating |

#### JDL App Generation

Expand Down
13 changes: 11 additions & 2 deletions src/boilerplate/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@ async function install (context) {
let jhipsterConfig
let jhipsterDirectory

// does the user want to use yarn?
let useNpm = !parameters.options.yarn
// `npm i` fails due to symlinks, so if the developer is using this boilerplate from a local directory, yarn is forced
if (context.parameters.options.boilerplate !== 'ignite-jhipster' && context.parameters.options.boilerplate !== 'jhipster') {
useNpm = false
}
ignite.useYarn = !useNpm

// if the user is passing in JDL
if (parameters.options.jdl) {
print.info('Importing JDL')
Expand Down Expand Up @@ -120,7 +128,8 @@ async function install (context) {
// attempt to install React Native or die trying
const rnInstall = await reactNative.install({
name,
version: getReactNativeVersion(context)
version: getReactNativeVersion(context),
useNpm: useNpm
})
if (rnInstall.exitCode > 0) process.exit(rnInstall.exitCode)

Expand Down Expand Up @@ -183,7 +192,7 @@ async function install (context) {
spinner.text = `▸ installing dependencies`
spinner.start()
// install any missing dependencies
await system.run('yarn', { stdio: 'ignore' })
await system.run(useNpm ? 'npm i' : 'yarn', { stdio: 'ignore' })
spinner.succeed(`dependencies installed`)
}
// pass long the debug flag if we're running in that mode
Expand Down

0 comments on commit 66ee637

Please sign in to comment.