Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGar <gar+gh@danger.computer>2021-07-28 01:38:07 +0300
committernlf <quitlahok@gmail.com>2021-10-15 00:41:20 +0300
commit24273a862e54abfd022df9fc4b8c250bfe77817c (patch)
treed23b525c0d2dfc5d7235d679802f5f595910dbc6 /test/lib/explain.js
parent0f69d295bd5516f496af75ef29e7ae6304fa2ba5 (diff)
feat(workspaces): add --include-workspace-root and explicit --no-workspacesfritzy/workspace-root
Adds a new config item that includes the workspace root. This also changes --workspaces to a trinary, so that setting it to false will explicitly exclude workspaces altogether. PR-URL: https://github.com/npm/cli/pull/3890 Credit: @fritzy Close: #3890 Reviewed-by: @wraithgar
Diffstat (limited to 'test/lib/explain.js')
-rw-r--r--test/lib/explain.js79
1 files changed, 78 insertions, 1 deletions
diff --git a/test/lib/explain.js b/test/lib/explain.js
index f690aeb2c..ebec13619 100644
--- a/test/lib/explain.js
+++ b/test/lib/explain.js
@@ -2,7 +2,7 @@ const t = require('tap')
const npm = {
prefix: null,
color: true,
- flatOptions: {},
+ flatOptions: { workspacesEnabled: true },
output: (...args) => {
OUTPUT.push(args)
},
@@ -301,3 +301,80 @@ t.test('workspaces', async t => {
})
})
})
+
+t.test('workspaces disabled', async t => {
+ npm.localPrefix = npm.prefix = t.testdir({
+ 'package.json': JSON.stringify({
+ name: 'workspaces-project',
+ version: '1.0.0',
+ workspaces: ['packages/*'],
+ dependencies: {
+ abbrev: '^1.0.0',
+ },
+ }),
+ node_modules: {
+ a: t.fixture('symlink', '../packages/a'),
+ b: t.fixture('symlink', '../packages/b'),
+ c: t.fixture('symlink', '../packages/c'),
+ once: {
+ 'package.json': JSON.stringify({
+ name: 'once',
+ version: '1.0.0',
+ dependencies: {
+ wrappy: '2.0.0',
+ },
+ }),
+ },
+ abbrev: {
+ 'package.json': JSON.stringify({
+ name: 'abbrev',
+ version: '1.0.0',
+ }),
+ },
+ wrappy: {
+ 'package.json': JSON.stringify({
+ name: 'wrappy',
+ version: '2.0.0',
+ }),
+ },
+ },
+ packages: {
+ a: {
+ 'package.json': JSON.stringify({
+ name: 'a',
+ version: '1.0.0',
+ dependencies: {
+ once: '1.0.0',
+ },
+ }),
+ },
+ b: {
+ 'package.json': JSON.stringify({
+ name: 'b',
+ version: '1.0.0',
+ dependencies: {
+ abbrev: '^1.0.0',
+ },
+ }),
+ },
+ c: {
+ 'package.json': JSON.stringify({
+ name: 'c',
+ version: '1.0.0',
+ }),
+ },
+ },
+ })
+
+ await new Promise((res, rej) => {
+ explain.npm.flatOptions.workspacesEnabled = false
+ explain.exec(['once'], err => {
+ t.equal(
+ err,
+ 'No dependencies found matching once',
+ 'should throw usage if dep not found when excluding ws'
+ )
+ res()
+ })
+ })
+})