diff --git a/README.md b/README.md index c9d7fe1fb..017b2f5db 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/lib/packagers/yarn.js b/lib/packagers/yarn.js index 8895f5cbf..78083cff3 100644 --- a/lib/packagers/yarn.js +++ b/lib/packagers/yarn.js @@ -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'); @@ -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'); } diff --git a/lib/packagers/yarn.test.js b/lib/packagers/yarn.test.js index 676aa3d3e..0420bee50 100644 --- a/lib/packagers/yarn.test.js +++ b/lib/packagers/yarn.test.js @@ -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' } @@ -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' }