Skip to content

Commit

Permalink
use npm ci
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonocasey committed Sep 13, 2018
1 parent 490501f commit ae9f4d7
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
22 changes: 21 additions & 1 deletion generators/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const constants = require('./constants');
const naming = require('./naming');
const packageJSON = require('./package-json');
const validators = require('./validators');
const spawnSync = require('child_process').spawnSync;

module.exports = class extends Generator {

Expand Down Expand Up @@ -327,7 +328,26 @@ module.exports = class extends Generator {
* we don't want to run that (or depend on it in any way).
*/
install() {
this.npmInstall();
const result = spawnSync('npm', ['--version']);

// no access to npm uh oh, lets let yeoman throw an error
if (result.status !== 0) {
return this.npmInstall();
}

// get the major version for npm
const major = parseFloat(result.stdout.toString().trim().split('.')[0]);

if (!major || major <= 5) {
return this.npmInstall();
}

// if we are on npm greater than 6
// save time by updating package-lock-only
// and then running npm ci
spawnSync('npm', ['i', '--package-lock-only'], {stdio: 'inherit', cwd: this.destinationRoot()});
spawnSync('npm', ['ci'], {stdio: 'inherit', cwd: this.destinationRoot()});

}

/**
Expand Down
6 changes: 2 additions & 4 deletions scripts/run-integration-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ let tempDir;
helpers.run(libs.GENERATOR_PATH)
.inTmpDir(function(dir) {
tempDir = dir;
console.log(`Generating Project in ${tempDir}`);
})
.withOptions(libs.options())
.withOptions(Object.assign(libs.options(), {skipInstall: false}))
.withPrompts({
name: 'integration-test',
author: 'John Doe',
Expand Down Expand Up @@ -46,9 +47,6 @@ helpers.run(libs.GENERATOR_PATH)

const commands = [
['git', 'init'],
// mimics yeoman install command
['npm', 'install', '--cache-min', '86400'],
['npm', 'ci'],
['git', 'add', '--all'],
['git', 'commit', '-a', '-m', 'feat: initial release!'],
['npm', 'version', 'prerelease'],
Expand Down

0 comments on commit ae9f4d7

Please sign in to comment.