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

feat(packager): add noInstall option #1003

Merged
merged 3 commits into from
Nov 19, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,11 @@ configuration setting. For details see below.
By default, the plugin uses NPM to package the external modules. However, if you use npm,
you should use any version `<5.5 >=5.7.1` as the versions in-between have some nasty bugs.

Right now there are no `packagerOptions` that can be set with NPM.
The NPM packager supports the following `packagerOptions`:

| Option | Type | Default | Description |
| ------------------ | ---- | ------- | --------------------------------------------------- |
| noInstall | bool | false | Do not run `npm install` (assume install completed) |

##### Yarn

Expand All @@ -382,6 +386,7 @@ The yarn packager supports the following `packagerOptions`:
| Option | Type | Default | Description |
| ------------------ | ---- | ------- | --------------------------------------------------- |
| ignoreScripts | bool | false | Do not execute package.json hook scripts on install |
| noInstall | bool | false | Do not run `yarn install` (assume install completed)|
| noFrozenLockfile | bool | false | Do not require an up-to-date yarn.lock |
| networkConcurrency | int | | Specify number of concurrent network requests |

Expand Down
5 changes: 4 additions & 1 deletion lib/packagers/npm.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,10 @@ class NPM {
return lockfile;
}

static install(cwd) {
static install(cwd, packagerOptions) {
if (packagerOptions.noInstall) {
return BbPromise.resolve();
}
j0k3r marked this conversation as resolved.
Show resolved Hide resolved
const command = /^win/.test(process.platform) ? 'npm.cmd' : 'npm';
const args = ['install'];

Expand Down
12 changes: 11 additions & 1 deletion lib/packagers/npm.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ describe('npm', () => {
describe('install', () => {
it('should use npm install', () => {
Utils.spawnProcess.returns(BbPromise.resolve({ stdout: 'installed successfully', stderr: '' }));
return expect(npmModule.install('myPath')).to.be.fulfilled.then(result => {
return expect(npmModule.install('myPath', {})).to.be.fulfilled.then(result => {
expect(result).to.be.undefined;
expect(Utils.spawnProcess).to.have.been.calledOnce;
expect(Utils.spawnProcess).to.have.been.calledWithExactly(sinon.match(/^npm/), ['install'], {
Expand All @@ -60,6 +60,16 @@ describe('npm', () => {
});
});

describe('noInstall', () => {
it('should skip npm install', () => {
return expect(npmModule.install('myPath', { noInstall: true })).to.be.fulfilled.then(result => {
expect(result).to.be.undefined;
expect(Utils.spawnProcess).not.to.have.been.called;
return null;
});
});
});

describe('prune', () => {
it('should use npm prune', () => {
Utils.spawnProcess.returns(BbPromise.resolve({ stdout: 'success', stderr: '' }));
Expand Down
4 changes: 4 additions & 0 deletions lib/packagers/yarn.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ class Yarn {
}

static install(cwd, packagerOptions) {
if (packagerOptions.noInstall) {
return BbPromise.resolve();
}

const command = /^win/.test(process.platform) ? 'yarn.cmd' : 'yarn';
const args = [ 'install', '--non-interactive' ];

Expand Down
9 changes: 9 additions & 0 deletions lib/packagers/yarn.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,15 @@ describe('yarn', () => {
});
});

describe('noInstall', () => {
it('should skip yarn install', () => {
return expect(yarnModule.install('myPath', { noInstall: true })).to.be.fulfilled.then(result => {
expect(result).to.be.undefined;
return null;
});
});
});

describe('prune', () => {
let installStub;

Expand Down