fix(env): --global related error messages (#7456)

This commit is contained in:
Hyunbin
2023-12-26 20:59:34 +09:00
committed by GitHub
parent 09f6103490
commit 4d2923858a
4 changed files with 18 additions and 12 deletions

View File

@@ -0,0 +1,6 @@
---
"@pnpm/plugin-commands-env": patch
"pnpm": patch
---
Fix error message texts in the `pnpm env` commands [#7456](https://github.com/pnpm/pnpm/pull/7456).

View File

@@ -1,11 +1,11 @@
/* eslint-disable no-await-in-loop */
import { PnpmError } from '@pnpm/error'
import { type NvmNodeCommandOptions } from './node'
import { downloadNodeVersion } from './downloadNodeVersion'
import { type NvmNodeCommandOptions } from './node'
export async function envAdd (opts: NvmNodeCommandOptions, params: string[]) {
if (!opts.global) {
throw new PnpmError('NOT_IMPLEMENTED_YET', '"pnpm env use <version>" can only be used with the "--global" option currently')
throw new PnpmError('NOT_IMPLEMENTED_YET', '"pnpm env add <version>" can only be used with the "--global" option currently')
}
const failed: string[] = []
for (const envSpecifier of params) {

View File

@@ -1,17 +1,17 @@
/* eslint-disable no-await-in-loop */
import { existsSync } from 'fs'
import path from 'path'
import { PnpmError } from '@pnpm/error'
import { logger, globalInfo } from '@pnpm/logger'
import { globalInfo, logger } from '@pnpm/logger'
import { removeBin } from '@pnpm/remove-bins'
import rimraf from '@zkochan/rimraf'
import { getNodeExecPathAndTargetDir } from './utils'
import { getNodeVersionsBaseDir, type NvmNodeCommandOptions } from './node'
import { existsSync } from 'fs'
import path from 'path'
import { getNodeVersion } from './downloadNodeVersion'
import { getNodeVersionsBaseDir, type NvmNodeCommandOptions } from './node'
import { getNodeExecPathAndTargetDir } from './utils'
export async function envRemove (opts: NvmNodeCommandOptions, params: string[]) {
if (!opts.global) {
throw new PnpmError('NOT_IMPLEMENTED_YET', '"pnpm env use <version>" can only be used with the "--global" option currently')
throw new PnpmError('NOT_IMPLEMENTED_YET', '"pnpm env remove <version>" can only be used with the "--global" option currently')
}
let failed = false

View File

@@ -1,10 +1,10 @@
import fs from 'fs'
import path from 'path'
import { PnpmError } from '@pnpm/error'
import { tempDir } from '@pnpm/prepare'
import { env } from '@pnpm/plugin-commands-env'
import { tempDir } from '@pnpm/prepare'
import * as execa from 'execa'
import fs from 'fs'
import nock from 'nock'
import path from 'path'
import PATH from 'path-name'
import semver from 'semver'
@@ -147,7 +147,7 @@ describe('env add/remove', () => {
pnpmHomeDir: process.cwd(),
rawConfig: {},
}, ['remove', 'lts'])
).rejects.toEqual(new PnpmError('NOT_IMPLEMENTED_YET', '"pnpm env use <version>" can only be used with the "--global" option currently'))
).rejects.toEqual(new PnpmError('NOT_IMPLEMENTED_YET', '"pnpm env remove <version>" can only be used with the "--global" option currently'))
})
test('fail if can not resolve Node.js version', async () => {