Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -361,9 +361,10 @@ Using yarn will switch the whole packaging pipeline to use yarn, so does it use

The yarn packager supports the following `packagerOptions`:

| Option | Type | Default | Description |
|---------------|------|---------|-------------|
| ignoreScripts | bool | true | Do not execute package.json hook scripts on install |
| Option | Type | Default | Description |
|------------------|------|----------|-----------------------------------------------------|
| ignoreScripts | bool | false | Do not execute package.json hook scripts on install |
| noFrozenLockfile | bool | false | Do not require an up-to-date yarn.lock |

##### Common packager options

Expand Down
6 changes: 5 additions & 1 deletion lib/packagers/yarn.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* Yarn specific packagerOptions (default):
* flat (false) - Use --flat with install
* ignoreScripts (false) - Do not execute scripts during install
* noFrozenLockfile (false) - Do not require an up-to-date yarn.lock
*/

const _ = require('lodash');
Expand Down Expand Up @@ -117,9 +118,12 @@ class Yarn {

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

// Convert supported packagerOptions
if (!packagerOptions.noFrozenLockfile) {
args.push('--frozen-lockfile');
}
if (packagerOptions.ignoreScripts) {
args.push('--ignore-scripts');
}
Expand Down
20 changes: 18 additions & 2 deletions lib/packagers/yarn.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ describe('yarn', () => {
expect(Utils.spawnProcess).to.have.been.calledOnce;
expect(Utils.spawnProcess).to.have.been.calledWithExactly(
sinon.match(/^yarn/),
[ 'install', '--pure-lockfile', '--non-interactive' ],
[ 'install', '--non-interactive', '--frozen-lockfile' ],
{
cwd: 'myPath'
}
Expand All @@ -234,7 +234,23 @@ describe('yarn', () => {
expect(Utils.spawnProcess).to.have.been.calledOnce;
expect(Utils.spawnProcess).to.have.been.calledWithExactly(
sinon.match(/^yarn/),
[ 'install', '--pure-lockfile', '--non-interactive', '--ignore-scripts' ],
[ 'install', '--non-interactive', '--frozen-lockfile', '--ignore-scripts' ],
{
cwd: 'myPath'
}
);
return null;
});
});

it('should use noFrozenLockfile option', () => {
Utils.spawnProcess.returns(BbPromise.resolve({ stdout: 'installed successfully', stderr: '' }));
return expect(yarnModule.install('myPath', { noFrozenLockfile: true })).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(/^yarn/),
[ 'install', '--non-interactive' ],
{
cwd: 'myPath'
}
Expand Down