diff --git a/README.md b/README.md index 98acdd628..680ba3e96 100644 --- a/README.md +++ b/README.md @@ -425,6 +425,7 @@ The yarn packager supports the following `packagerOptions`: | ------------------ | ---- | ------- | --------------------------------------------------- | | ignoreScripts | bool | false | Do not execute package.json hook scripts on install | | noInstall | bool | false | Do not run `yarn install` (assume install completed)| +| noNonInteractive | bool | false | Disable interactive mode when using Yarn 2 or above | | noFrozenLockfile | bool | false | Do not require an up-to-date yarn.lock | | networkConcurrency | int | | Specify number of concurrent network requests | diff --git a/lib/packagers/yarn.js b/lib/packagers/yarn.js index f8322d859..d03f700ec 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 + * noNonInteractive (false) - Disable interactive mode when using Yarn 2 or above * noFrozenLockfile (false) - Do not require an up-to-date yarn.lock * networkConcurrency (8) - Specify number of concurrent network requests */ @@ -123,9 +124,12 @@ class Yarn { } const command = /^win/.test(process.platform) ? 'yarn.cmd' : 'yarn'; - const args = ['install', '--non-interactive']; + const args = ['install']; // Convert supported packagerOptions + if (!packagerOptions.noNonInteractive) { + args.push('--non-interactive'); + } if (!packagerOptions.noFrozenLockfile) { args.push('--frozen-lockfile'); } diff --git a/tests/packagers/yarn.test.js b/tests/packagers/yarn.test.js index 6c5a3b37f..9db6cf789 100644 --- a/tests/packagers/yarn.test.js +++ b/tests/packagers/yarn.test.js @@ -213,6 +213,23 @@ describe('yarn', () => { }); }); + it('should use noNonInteractive option', () => { + Utils.spawnProcess.mockReturnValue(BbPromise.resolve({ stdout: 'installed successfully', stderr: '' })); + return expect(yarnModule.install('myPath', { noNonInteractive: true })) + .resolves.toBeUndefined() + .then(() => { + expect(Utils.spawnProcess).toHaveBeenCalledTimes(1); + expect(Utils.spawnProcess).toHaveBeenCalledWith( + expect.stringMatching(/^yarn/), + ['install', '--frozen-lockfile'], + { + cwd: 'myPath' + } + ); + return null; + }); + }); + it('should use ignoreScripts option', () => { Utils.spawnProcess.mockReturnValue(BbPromise.resolve({ stdout: 'installed successfully', stderr: '' })); return expect(yarnModule.install('myPath', { ignoreScripts: true }))