feat(env): show state on fetching node (#5241)

* feat(env): show state on fetching node

* fix: use internal logger instead of console.log

* chore: add changeset
This commit is contained in:
JacobLinCool
2022-08-23 00:24:09 +08:00
committed by GitHub
parent 1c7b439bbe
commit c242672f5a
4 changed files with 11 additions and 0 deletions

View File

@@ -0,0 +1,5 @@
---
"@pnpm/plugin-commands-env": minor
---
Add an immediate response when fetching Node.js on version switching, preventing pnpm looks like just hanging there.

View File

@@ -34,6 +34,7 @@
"@pnpm/config": "workspace:*",
"@pnpm/error": "workspace:*",
"@pnpm/fetch": "workspace:*",
"@pnpm/logger": "^4.0.0",
"@pnpm/node.fetcher": "workspace:*",
"@pnpm/node.resolver": "workspace:*",
"@pnpm/store-path": "workspace:*",

View File

@@ -2,6 +2,7 @@ import fs from 'fs'
import path from 'path'
import { Config } from '@pnpm/config'
import { createFetchFromRegistry, FetchFromRegistry } from '@pnpm/fetch'
import { globalInfo } from '@pnpm/logger'
import { fetchNode } from '@pnpm/node.fetcher'
import storePath from '@pnpm/store-path'
import loadJsonFile from 'load-json-file'
@@ -71,6 +72,7 @@ export async function getNodeDir (fetch: FetchFromRegistry, opts: NvmNodeCommand
pnpmHomeDir: opts.pnpmHomeDir,
})
const cafsDir = path.join(storeDir, 'files')
globalInfo(`Fetching Node.js ${opts.useNodeVersion} ...`)
await fetchNode(fetch, opts.useNodeVersion, versionDir, {
...opts,
cafsDir,

3
pnpm-lock.yaml generated
View File

@@ -3060,6 +3060,9 @@ importers:
'@pnpm/fetch':
specifier: workspace:*
version: link:../fetch
'@pnpm/logger':
specifier: ^4.0.0
version: 4.0.0
'@pnpm/node.fetcher':
specifier: workspace:*
version: link:../node.fetcher