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

Add new packagerOptions: noNonInteractive to disable interactive mode when using Yarn 2 or above #1246

Merged
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |

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
* 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
*/
Expand Down Expand Up @@ -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');
}
Expand Down
17 changes: 17 additions & 0 deletions tests/packagers/yarn.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }))
Expand Down