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

Treat the ignore-scripts in yarnrc as a synonym to the cli arg #6983

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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Expand Up @@ -8,6 +8,10 @@ Please add one entry in this file for each change in Yarn's behavior. Use the sa

[#6951](https://github.com/yarnpkg/yarn/pull/6951) - [**John-David Dalton**](https://twitter.com/jdalton)

- Packages won't be auto-unplugged anymore if `ignore-scripts` is set in the yarnrc file

[#6983](https://github.com/yarnpkg/yarn/pull/6983) - [**Micha Reiser**](https://github.com/MichaReiser)

## 1.14.0

- Improves PnP compatibility with Node 6
Expand Down
1 change: 1 addition & 0 deletions __tests__/commands/_helpers.js
Expand Up @@ -85,6 +85,7 @@ export function makeConfigFromDirectory(cwd: string, reporter: Reporter, flags:
{
binLinks: !!flags.binLinks,
cwd,
ignoreScripts: flags.ignoreScripts,
globalFolder: flags.globalFolder || path.join(cwd, '.yarn-global'),
cacheFolder: flags.cacheFolder || path.join(cwd, '.yarn-cache'),
linkFolder: flags.linkFolder || path.join(cwd, '.yarn-link'),
Expand Down
1 change: 1 addition & 0 deletions __tests__/commands/check.js
Expand Up @@ -215,6 +215,7 @@ test.concurrent('--integrity should fail if --ignore-scripts is changed', async
async (config, reporter, install, getStdout): Promise<void> => {
let thrown = false;
try {
config.ignoreScripts = false;
await checkCmd.run(config, reporter, {integrity: true, ignoreScripts: false}, []);
} catch (e) {
thrown = true;
Expand Down
8 changes: 8 additions & 0 deletions __tests__/commands/install/integration.js
Expand Up @@ -1139,3 +1139,11 @@ test('install will not warn for missing optional peer dependencies', () =>
const warningMessage = messageParts.every(part => stdout.includes(part));
expect(warningMessage).toBe(false);
}));

test('install skips the scripts if the yarnrc specifies skip-scripts true', () =>
runInstall({}, 'ignore-scripts-by-yarnrc', (config, reporter, install, getStdout) => {
const stdout = getStdout();

const ignoredScriptsMessage = reporter.lang('ignoredScripts');
expect(stdout).toMatch(ignoredScriptsMessage);
}));
5 changes: 5 additions & 0 deletions __tests__/commands/install/offline-mirror.js
Expand Up @@ -35,6 +35,7 @@ test.concurrent(

// enable packing of built artifacts
config.packBuiltPackages = true;
config.ignoreScripts = false;

// after first run we observe both package and global side effects
let reinstall = new Install({force: true}, config, reporter, await Lockfile.fromDirectory(config.cwd));
Expand Down Expand Up @@ -64,6 +65,7 @@ test.concurrent(

// enable packing of built artifacts
config.packBuiltPackages = true;
config.ignoreScripts = false;

// after first run we observe package side effects
let reinstall = new Install({force: true}, config, reporter, await Lockfile.fromDirectory(config.cwd));
Expand All @@ -89,6 +91,8 @@ test.concurrent('install without pack-built-packages should keep running install
expect(await fs.exists(path.join(config.cwd, 'node_modules', 'dep-a', 'module-a-build.log'))).toEqual(false);
expect(await fs.exists(path.join(config.cwd, 'module-a-build.log'))).toEqual(false);

config.ignoreScripts = false;

// after first run we observe both package and global side effects
let reinstall = new Install({force: true}, config, reporter, await Lockfile.fromDirectory(config.cwd));
await reinstall.init();
Expand All @@ -113,6 +117,7 @@ test.concurrent('removing prebuilt package .tgz file falls back to running scrip

// enable packing of built artifacts
config.packBuiltPackages = true;
config.ignoreScripts = false;

// after first run we observe both package and global side effects
let reinstall = new Install({force: true}, config, reporter, await Lockfile.fromDirectory(config.cwd));
Expand Down
2 changes: 2 additions & 0 deletions __tests__/fixtures/install/ignore-scripts-by-yarnrc/.yarnrc
@@ -0,0 +1,2 @@
yarn-offline-mirror "./mirror-for-offline"
ignore-scripts true
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,5 @@
{
"dependencies": {
"dep-a": "1.0.0"
}
}
18 changes: 18 additions & 0 deletions __tests__/fixtures/install/ignore-scripts-by-yarnrc/yarn.lock
@@ -0,0 +1,18 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1
dep-a@1.0.0:
version "1.0.0"
resolved dep-a-1.0.0.tgz#63970c7301ec8a5d37dac4e454fff354f31c31b4
integrity sha1-Y5cMcwHsil032sTkVP/zVPMcMbQ=
dependencies:
dep-b "1.0.0"
dep-b@1.0.0:
version "1.0.0"
resolved dep-b-1.0.0.tgz#569c27a4e30b1679eaa7e2299e741f30a7f70926
integrity sha1-VpwnpOMLFnnqp+IpnnQfMKf3CSY=
dependencies:
dep-c "1.0.0"
dep-c@1.0.0:
version "1.0.0"
resolved dep-c-1.0.0.tgz#100eef2bf00fc31b596542fb9af18186e37716cc
integrity sha1-EA7vK/APwxtZZUL7mvGBhuN3Fsw=
3 changes: 1 addition & 2 deletions src/cli/commands/install.js
Expand Up @@ -56,7 +56,6 @@ type Flags = {
har: boolean,
ignorePlatform: boolean,
ignoreEngines: boolean,
ignoreScripts: boolean,
ignoreOptional: boolean,
linkDuplicates: boolean,
force: boolean,
Expand Down Expand Up @@ -685,7 +684,7 @@ export class Install {
emoji.get('hammer'),
);

if (this.flags.ignoreScripts) {
if (this.config.ignoreScripts) {
this.reporter.warn(this.reporter.lang('ignoredScripts'));
} else {
await this.scripts.init(flattenedTopLevelPatterns);
Expand Down
2 changes: 2 additions & 0 deletions src/config.js
Expand Up @@ -416,6 +416,8 @@ export default class Config {
this.plugnplayShebang = String(this.getOption('plugnplay-shebang') || '') || '/usr/bin/env node';
this.plugnplayBlacklist = String(this.getOption('plugnplay-blacklist') || '') || null;

this.ignoreScripts = opts.ignoreScripts || Boolean(this.getOption('ignore-scripts', false));

this.workspacesEnabled = this.getOption('workspaces-experimental') !== false;
this.workspacesNohoistEnabled = this.getOption('workspaces-nohoist-experimental') !== false;

Expand Down
3 changes: 2 additions & 1 deletion src/integrity-checker.js
Expand Up @@ -237,7 +237,8 @@ export default class InstallationIntegrityChecker {
if (flags.flat) {
result.flags.push('flat');
}
if (flags.ignoreScripts) {

if (this.config.ignoreScripts) {
result.flags.push('ignoreScripts');
}
if (this.config.focus) {
Expand Down