Skip to content

Commit

Permalink
feat: add --ci flag to grow install
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremydw committed Sep 16, 2021
1 parent 1f9d9f3 commit f004a40
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 5 additions & 1 deletion grow/commands/subcommands/install.py
Expand Up @@ -22,7 +22,10 @@
'known Gerrit host amongst the remotes in your repository.')
@click.option('--force', '-f', default=False, is_flag=True,
help='Whether to force install even when no changes found.')
def install(pod_path, gerrit, force):
@click.option('--ci/--no-ci', default=False,
help='Whether to use the `npm ci` command instead of the '
'`npm install` command.')
def install(pod_path, gerrit, force, ci):
"""Checks whether the pod depends on npm, bower, and gulp and installs them
if necessary. Then, runs install commands. Also optionally installs the
Gerrit Code Review commit hook."""
Expand All @@ -33,6 +36,7 @@ def install(pod_path, gerrit, force):
config = base_config.BaseConfig()
config.set('gerrit', gerrit)
config.set('force', force)
config.set('ci', ci)
built_in_installers = []
for installer_class in installers.BUILT_IN_INSTALLERS:
built_in_installers.append(installer_class(pod, config))
Expand Down
6 changes: 4 additions & 2 deletions grow/sdk/installers/npm_installer.py
Expand Up @@ -97,14 +97,16 @@ def _generate_hashes(self):

def _install_npm(self):
"""Install dependencies using npm."""
install_command = self._nvm_command('npm install')
command = 'npm install' if not self.config.get('ci') else 'npm ci'
install_command = self._nvm_command(command)
self.pod.logger.info('Running: {}'.format(install_command))
process = subprocess.Popen(install_command, **self.subprocess_args(shell=True))
code = process.wait()
if not code:
self.pod.write_file(INSTALL_HASH_FILE, self._generate_hashes())
return
raise base_installer.InstallError(
'There was an error running `npm install`.')
'There was an error running `{}`.'.format(command))

def _install_yarn(self):
"""Install dependencies using npm."""
Expand Down

0 comments on commit f004a40

Please sign in to comment.