diff --git a/__tests__/commands/install/workspaces-install.js b/__tests__/commands/install/workspaces-install.js index 89584ed57e..8f3ce3b92a 100644 --- a/__tests__/commands/install/workspaces-install.js +++ b/__tests__/commands/install/workspaces-install.js @@ -157,6 +157,17 @@ test.concurrent('install should prioritize non workspace dependency at root over }); }); +test.concurrent('install should run local install scripts', (): Promise => { + return runInstall({}, 'workspaces-install-scripts', async (config): Promise => { + expect(await fs.exists(path.join(config.cwd, 'node_modules', 'workspace-3', 'src.js'))).toBe(true); + expect(await fs.exists(path.join(config.cwd, 'node_modules', 'workspace-3', 'prepublish.js'))).toBe(true); + expect(await fs.exists(path.join(config.cwd, 'node_modules', 'workspace-3', 'prepublishOnly.js'))).toBe(true); + expect(await fs.exists(path.join(config.cwd, 'node_modules', 'workspace-3', 'prepare.js'))).toBe(true); + expect(await fs.exists(path.join(config.cwd, 'node_modules', 'workspace-3', 'preinstall.js'))).toBe(true); + expect(await fs.exists(path.join(config.cwd, 'node_modules', 'workspace-3', 'postinstall.js'))).toBe(true); + }); +}); + test.concurrent('install should install subedependencies of workspaces', (): Promise => { // the tricky part is that isarray is a subdependency of left-pad that is not referenced in the root // but another workspace diff --git a/__tests__/fixtures/install/workspaces-install-scripts/.yarnrc b/__tests__/fixtures/install/workspaces-install-scripts/.yarnrc new file mode 100644 index 0000000000..19daacaa08 --- /dev/null +++ b/__tests__/fixtures/install/workspaces-install-scripts/.yarnrc @@ -0,0 +1 @@ +workspaces-experimental true diff --git a/__tests__/fixtures/install/workspaces-install-scripts/package.json b/__tests__/fixtures/install/workspaces-install-scripts/package.json new file mode 100644 index 0000000000..8c7ecb54dc --- /dev/null +++ b/__tests__/fixtures/install/workspaces-install-scripts/package.json @@ -0,0 +1,10 @@ +{ + "name": "my-project", + "private": true, + "dependencies": { + "left-pad": "1.1.3" + }, + "workspaces": [ + "packages/*" + ] +} diff --git a/__tests__/fixtures/install/workspaces-install-scripts/packages/workspace-2/package.json b/__tests__/fixtures/install/workspaces-install-scripts/packages/workspace-2/package.json new file mode 100644 index 0000000000..eede68748c --- /dev/null +++ b/__tests__/fixtures/install/workspaces-install-scripts/packages/workspace-2/package.json @@ -0,0 +1,7 @@ +{ + "name": "workspace-2", + "version": "1.0.0", + "dependencies": { + "workspace-3": "1.0.0" + } +} diff --git a/__tests__/fixtures/install/workspaces-install-scripts/packages/workspace-2/src.js b/__tests__/fixtures/install/workspaces-install-scripts/packages/workspace-2/src.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/__tests__/fixtures/install/workspaces-install-scripts/packages/workspace-3/package.json b/__tests__/fixtures/install/workspaces-install-scripts/packages/workspace-3/package.json new file mode 100644 index 0000000000..43747d6cb3 --- /dev/null +++ b/__tests__/fixtures/install/workspaces-install-scripts/packages/workspace-3/package.json @@ -0,0 +1,14 @@ +{ + "name": "workspace-3", + "version": "1.0.0", + "scripts": { + "prepublish": "cpy src.js prepublish.js", + "prepublishOnly": "cpy src.js prepublishOnly.js", + "prepare": "cpy src.js prepare.js", + "preinstall": "cpy src.js preinstall.js", + "postinstall": "cpy src.js postinstall.js" + }, + "dependencies": { + "repeat-string": "1.6.1" + } +} diff --git a/__tests__/fixtures/install/workspaces-install-scripts/packages/workspace-3/src.js b/__tests__/fixtures/install/workspaces-install-scripts/packages/workspace-3/src.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/__tests__/fixtures/request-cache/GET/registry.npmjs.org/isarray.bin b/__tests__/fixtures/request-cache/GET/registry.npmjs.org/isarray.bin new file mode 100644 index 0000000000..04f57c2f87 Binary files /dev/null and b/__tests__/fixtures/request-cache/GET/registry.npmjs.org/isarray.bin differ diff --git a/__tests__/fixtures/request-cache/GET/registry.npmjs.org/left-pad.bin b/__tests__/fixtures/request-cache/GET/registry.npmjs.org/left-pad.bin new file mode 100644 index 0000000000..7bd05f5d31 Binary files /dev/null and b/__tests__/fixtures/request-cache/GET/registry.npmjs.org/left-pad.bin differ diff --git a/__tests__/fixtures/request-cache/GET/registry.npmjs.org/repeat-string.bin b/__tests__/fixtures/request-cache/GET/registry.npmjs.org/repeat-string.bin new file mode 100644 index 0000000000..fc3f680989 Binary files /dev/null and b/__tests__/fixtures/request-cache/GET/registry.npmjs.org/repeat-string.bin differ diff --git a/__tests__/fixtures/request-cache/GET/registry.npmjs.org/right-pad.bin b/__tests__/fixtures/request-cache/GET/registry.npmjs.org/right-pad.bin new file mode 100644 index 0000000000..19b275658a Binary files /dev/null and b/__tests__/fixtures/request-cache/GET/registry.npmjs.org/right-pad.bin differ