fix: WMIC is being removed (#10223)

* fix: `WMI` is being removed

* fix: update

* fix: update

* fix: validate drive before usage

* fix: remove not needed dep

* refactor: regex

---------

Co-authored-by: Zoltan Kochan <z@kochan.io>
This commit is contained in:
btea
2025-11-27 21:08:12 +08:00
committed by GitHub
parent 60b5fd17ed
commit 7cec347701
4 changed files with 11 additions and 8 deletions

View File

@@ -0,0 +1,5 @@
---
"@pnpm/worker": patch
---
`WMIC` has been deprecated and replaced by PowerShell commands.

3
pnpm-lock.yaml generated
View File

@@ -8730,9 +8730,6 @@ importers:
p-limit:
specifier: 'catalog:'
version: 7.1.0
shlex:
specifier: 'catalog:'
version: 3.0.0
devDependencies:
'@pnpm/logger':
specifier: workspace:*

View File

@@ -43,8 +43,7 @@
"@pnpm/symlink-dependency": "workspace:*",
"@rushstack/worker-pool": "catalog:",
"is-windows": "catalog:",
"p-limit": "catalog:",
"shlex": "catalog:"
"p-limit": "catalog:"
},
"peerDependencies": {
"@pnpm/logger": "catalog:"

View File

@@ -8,7 +8,6 @@ import isWindows from 'is-windows'
import { type PackageFilesIndex } from '@pnpm/store.cafs'
import { type DependencyManifest } from '@pnpm/types'
import pLimit from 'p-limit'
import { join as shellQuote } from 'shlex'
import {
type TarballExtractMessage,
type AddDirToStoreMessage,
@@ -269,11 +268,14 @@ function createErrorHint (err: Error, checkedDir: string): string | undefined {
// In Windows system exFAT drive, symlink will result in error.
function isDriveExFat (drive: string): boolean {
if (!/^[a-z]:$/i.test(drive)) {
throw new Error(`${drive} is not a valid disk on Windows`)
}
try {
// cspell:disable-next-line
const output = execSync(`wmic logicaldisk where ${shellQuote([`DeviceID='${drive}'`])} get FileSystem`).toString()
const output = execSync(`powershell -Command "Get-Volume -DriveLetter ${drive.replace(':', '')} | Select-Object -ExpandProperty FileSystem"`).toString()
const lines = output.trim().split('\n')
const name = lines.length > 1 ? lines[1].trim() : ''
const name = lines[0].trim()
return name === 'exFAT'
} catch {
return false