Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use $ npm ci if there is a lockfile #310

Merged
merged 6 commits into from
Jan 3, 2019
Merged

Use $ npm ci if there is a lockfile #310

merged 6 commits into from
Jan 3, 2019

Conversation

yaodingyd
Copy link
Contributor

@yaodingyd yaodingyd commented Dec 28, 2018

Fixes #285

index.js Outdated Show resolved Hide resolved
index.js Outdated Show resolved Hide resolved
@sindresorhus sindresorhus changed the title use npm ci if there is lock file (#285) Use $ npm ci if there is lockfile Dec 28, 2018
index.js Outdated
@@ -46,6 +47,7 @@ module.exports = async (input = 'patch', options) => {
const pkg = util.readPkg();
const pkgManager = options.yarn === true ? 'yarn' : 'npm';
const pkgManagerName = options.yarn === true ? 'Yarn' : 'npm';
const hasLockFile = fs.existsSync('package-lock.json') || fs.existsSync('npm-shrinkwrap.json');
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just realized, you have to make the paths here relative to the package root, as it should be possible to run np in a sub-folder.

You can get the root path with https://github.com/sindresorhus/pkg-dir

index.js Outdated Show resolved Hide resolved
@sindresorhus sindresorhus changed the title Use $ npm ci if there is lockfile Use $ npm ci if there is a lockfile Dec 28, 2018
index.js Outdated
@@ -65,6 +70,7 @@ module.exports = async (input = 'patch', options) => {
tasks.add([
{
title: 'Cleanup',
skip: hasLockFile,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be a function.

index.js Outdated
task: () => exec('npm', ['install', '--no-package-lock', '--no-production'])
task: () => {
const args = hasLockFile ? ['ci'] : ['install', '--no-package-lock', '--no-production'];
exec('npm', args);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You forgot to return this, so the task would wait for it.

@sindresorhus sindresorhus merged commit e60f8f4 into sindresorhus:master Jan 3, 2019
@yaodingyd yaodingyd deleted the ci branch January 3, 2019 13:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants