@@ -17,7 +17,6 @@ function BrowserslistUpdateError(message) {
1717
1818BrowserslistUpdateError . prototype = Error . prototype
1919
20- // Check if HADOOP_HOME is set to determine if this is running in a Hadoop environment
2120const YARN_CMD = process . env . HADOOP_HOME ? 'yarnpkg' : 'yarn'
2221
2322/* c8 ignore next 3 */
@@ -71,8 +70,6 @@ function getLatestInfo(lock) {
7170 if ( lock . mode === 'yarn' ) {
7271 if ( lock . version === 1 ) {
7372 let yarnMajorVersion = getYarnMajor ( )
74- // If someone has yarn 2 or above they would get an opaque error.
75- // Instead we will explicitly tell them they need to use classic.
7673 if ( yarnMajorVersion !== 1 ) {
7774 throw new BrowserslistUpdateError (
7875 'This project has a Yarn v1 (classic) lockfile, but the installed ' +
@@ -111,7 +108,6 @@ function getLatestInfo(lock) {
111108 // command`. Anchor that phrase to the binary we actually launched so an
112109 // unrelated "is not recognized" line in a real failure's output (e.g. a
113110 // nested tool) is not mistaken for a missing package manager.
114- // Only yarn's binary differs from lock.mode (it may be `yarnpkg`).
115111 let binary = lock . mode === 'yarn' ? YARN_CMD : lock . mode
116112 let missingOnWindows = new RegExp (
117113 "'" + binary + "' is not recognized as an internal or external command"
@@ -133,8 +129,6 @@ function getLatestInfo(lock) {
133129 }
134130}
135131
136- // Read the major version of the installed Yarn. A missing binary throws here
137- // and is handled by getLatestInfo's catch as the usual "not in PATH" message.
138132function getYarnMajor ( ) {
139133 let version = execSync ( YARN_CMD + ' --version' ) . toString ( ) . trim ( )
140134 return Number ( version . split ( '.' ) [ 0 ] )
@@ -372,15 +366,14 @@ function commandErrorText(error) {
372366 . join ( '\n' )
373367}
374368
375- // Windows shell only function
376369function quotePnpmArg ( arg ) {
377- // cmd.exe expands %VAR% and !VAR! even inside double quotes, and there is no
378- // reliable way to escape them on the command line. Refuse rather than run a
379- // mangled command; in practice our args (flags and JSON overrides) never
380- // contain them .
381- if ( / [ % ! ] / . test ( arg ) ) {
370+ // cmd.exe expands %VAR% and !VAR! even inside double quotes. It also ignores
371+ // the backslash in `\"`, so JSON values end up outside its quotes, where
372+ // ^ & | < > ( ) run commands or redirect output. Refuse rather than run
373+ // a mangled command .
374+ if ( / [ % ! ^ & | < > ( ) ] / . test ( arg ) ) {
382375 throw new BrowserslistUpdateError (
383- 'Cannot safely pass "%" or "!" to pnpm on Windows: ' + arg
376+ 'Cannot safely pass any of %!^&|<>() to pnpm on Windows: ' + arg
384377 )
385378 }
386379 if ( ! / [ \s " ] / . test ( arg ) ) return arg
@@ -392,14 +385,12 @@ function quotePnpmArg(arg) {
392385function runPnpm ( args , options = { } ) {
393386 // Node on Windows cannot launch pnpm's `.cmd` shim without a shell
394387 if ( process . platform === 'win32' ) {
395- // Shell requires arguments to be quoted
396388 return execFileSync ( 'pnpm' , args . map ( quotePnpmArg ) , {
397389 ...options ,
398390 shell : true
399391 } )
400392 }
401393
402- // On other platforms pnpm is spawned directly.
403394 return execFileSync ( 'pnpm' , args , options )
404395}
405396
0 commit comments