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-06-15 20:50:14 +0300
committerGar <gar+gh@danger.computer>2021-06-16 00:55:23 +0300
commit102d4e6fb3c3b02148dbeee977a7d1e6372340d5 (patch)
treeba2a004abbbcaeab08b839d3fba09992ec07f0ad /lib/version.js
parentc6a8734d7d6e4b6d061110a01e45e1d418d56489 (diff)
fix(workspaces): explicitly error in global mode
Also includes a preliminary refactor to consolidate workspace logic now that every command that supports workspaces has it implemented. PR-URL: https://github.com/npm/cli/pull/3417 Credit: @wraithgar Close: #3417 Reviewed-by: @ruyadorno
Diffstat (limited to 'lib/version.js')
-rw-r--r--lib/version.js13
1 files changed, 5 insertions, 8 deletions
diff --git a/lib/version.js b/lib/version.js
index 3ef3801e7..f3680fe8b 100644
--- a/lib/version.js
+++ b/lib/version.js
@@ -3,7 +3,6 @@ const { resolve } = require('path')
const { promisify } = require('util')
const readFile = promisify(require('fs').readFile)
-const getWorkspaces = require('./workspaces/get-workspaces.js')
const BaseCommand = require('./base-command.js')
class Version extends BaseCommand {
@@ -93,9 +92,8 @@ class Version extends BaseCommand {
async changeWorkspaces (args, filters) {
const prefix = this.npm.config.get('tag-version-prefix')
- const workspaces =
- await getWorkspaces(filters, { path: this.npm.localPrefix })
- for (const [name, path] of workspaces) {
+ await this.setWorkspaces(filters)
+ for (const [name, path] of this.workspaces) {
this.npm.output(name)
const version = await libnpmversion(args[0], {
...this.npm.flatOptions,
@@ -128,11 +126,10 @@ class Version extends BaseCommand {
async listWorkspaces (filters) {
const results = {}
- const workspaces =
- await getWorkspaces(filters, { path: this.npm.localPrefix })
- for (const [, path] of workspaces) {
+ await this.setWorkspaces(filters)
+ for (const path of this.workspacePaths) {
const pj = resolve(path, 'package.json')
- // getWorkspaces has already parsed this so we know it won't error
+ // setWorkspaces has already parsed package.json so we know it won't error
const pkg = await readFile(pj, 'utf8')
.then(data => JSON.parse(data))