diff --git a/CHANGELOG.md b/CHANGELOG.md index 1c1fb6a220..0b78a703e9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/__tests__/commands/_helpers.js b/__tests__/commands/_helpers.js index 1bd4d9f590..b7c641903b 100644 --- a/__tests__/commands/_helpers.js +++ b/__tests__/commands/_helpers.js @@ -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'), diff --git a/__tests__/commands/check.js b/__tests__/commands/check.js index f210e3a541..6a6b2d5d08 100644 --- a/__tests__/commands/check.js +++ b/__tests__/commands/check.js @@ -215,6 +215,7 @@ test.concurrent('--integrity should fail if --ignore-scripts is changed', async async (config, reporter, install, getStdout): Promise => { let thrown = false; try { + config.ignoreScripts = false; await checkCmd.run(config, reporter, {integrity: true, ignoreScripts: false}, []); } catch (e) { thrown = true; diff --git a/__tests__/commands/install/integration.js b/__tests__/commands/install/integration.js index 116f59c4c4..e3df495d88 100644 --- a/__tests__/commands/install/integration.js +++ b/__tests__/commands/install/integration.js @@ -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); + })); diff --git a/__tests__/commands/install/offline-mirror.js b/__tests__/commands/install/offline-mirror.js index 176f76d356..843a761674 100644 --- a/__tests__/commands/install/offline-mirror.js +++ b/__tests__/commands/install/offline-mirror.js @@ -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)); @@ -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)); @@ -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(); @@ -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)); diff --git a/__tests__/fixtures/install/ignore-scripts-by-yarnrc/.yarnrc b/__tests__/fixtures/install/ignore-scripts-by-yarnrc/.yarnrc new file mode 100644 index 0000000000..13e317bfda --- /dev/null +++ b/__tests__/fixtures/install/ignore-scripts-by-yarnrc/.yarnrc @@ -0,0 +1,2 @@ +yarn-offline-mirror "./mirror-for-offline" +ignore-scripts true \ No newline at end of file diff --git a/__tests__/fixtures/install/ignore-scripts-by-yarnrc/mirror-for-offline/dep-a-1.0.0.tgz b/__tests__/fixtures/install/ignore-scripts-by-yarnrc/mirror-for-offline/dep-a-1.0.0.tgz new file mode 100644 index 0000000000..8219cb9a7d Binary files /dev/null and b/__tests__/fixtures/install/ignore-scripts-by-yarnrc/mirror-for-offline/dep-a-1.0.0.tgz differ diff --git a/__tests__/fixtures/install/ignore-scripts-by-yarnrc/mirror-for-offline/dep-b-1.0.0.tgz b/__tests__/fixtures/install/ignore-scripts-by-yarnrc/mirror-for-offline/dep-b-1.0.0.tgz new file mode 100644 index 0000000000..511a7d4bc3 Binary files /dev/null and b/__tests__/fixtures/install/ignore-scripts-by-yarnrc/mirror-for-offline/dep-b-1.0.0.tgz differ diff --git a/__tests__/fixtures/install/ignore-scripts-by-yarnrc/mirror-for-offline/dep-c-1.0.0.tgz b/__tests__/fixtures/install/ignore-scripts-by-yarnrc/mirror-for-offline/dep-c-1.0.0.tgz new file mode 100644 index 0000000000..0b12d36e32 Binary files /dev/null and b/__tests__/fixtures/install/ignore-scripts-by-yarnrc/mirror-for-offline/dep-c-1.0.0.tgz differ diff --git a/__tests__/fixtures/install/ignore-scripts-by-yarnrc/package.json b/__tests__/fixtures/install/ignore-scripts-by-yarnrc/package.json new file mode 100644 index 0000000000..c0d4b7cf22 --- /dev/null +++ b/__tests__/fixtures/install/ignore-scripts-by-yarnrc/package.json @@ -0,0 +1,5 @@ +{ + "dependencies": { + "dep-a": "1.0.0" + } +} diff --git a/__tests__/fixtures/install/ignore-scripts-by-yarnrc/yarn.lock b/__tests__/fixtures/install/ignore-scripts-by-yarnrc/yarn.lock new file mode 100644 index 0000000000..b044b0d81d --- /dev/null +++ b/__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= diff --git a/src/cli/commands/install.js b/src/cli/commands/install.js index e72e2b6924..962520d48f 100644 --- a/src/cli/commands/install.js +++ b/src/cli/commands/install.js @@ -56,7 +56,6 @@ type Flags = { har: boolean, ignorePlatform: boolean, ignoreEngines: boolean, - ignoreScripts: boolean, ignoreOptional: boolean, linkDuplicates: boolean, force: boolean, @@ -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); diff --git a/src/config.js b/src/config.js index e09d8e5b34..77de5c4889 100644 --- a/src/config.js +++ b/src/config.js @@ -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; diff --git a/src/integrity-checker.js b/src/integrity-checker.js index 3f4ab4dbf1..c1f7500d26 100644 --- a/src/integrity-checker.js +++ b/src/integrity-checker.js @@ -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) {