Skip to content

Commit 3abde56

Browse files
committed
Fix an issue with double-quoting in install-run.
1 parent 00f1fb1 commit 3abde56

File tree

1 file changed

+10
-25
lines changed

1 file changed

+10
-25
lines changed

libraries/rush-lib/src/scripts/install-run.ts

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,6 @@ function _resolvePackageVersion(
176176
supportEnvVarFallbackSyntax: false
177177
});
178178

179-
const npmPath: string = getNpmPath();
180-
181179
// This returns something that looks like:
182180
// ```
183181
// [
@@ -196,17 +194,13 @@ function _resolvePackageVersion(
196194
//
197195
// if only a single version matches.
198196

199-
const spawnSyncOptions: childProcess.SpawnSyncOptions = {
200-
cwd: rushTempFolder,
201-
stdio: []
202-
};
203-
const platformNpmPath: string = _getPlatformPath(npmPath);
204-
205197
const npmVersionSpawnResult: childProcess.SpawnSyncReturns<Buffer | string> =
206-
_runAsShellCommandAndConfirmSuccess(
207-
platformNpmPath,
198+
_runNpmAsShellCommandAndConfirmSuccess(
208199
['view', `${name}@${version}`, 'version', '--no-update-notifier', '--json'],
209-
spawnSyncOptions,
200+
{
201+
cwd: rushTempFolder,
202+
stdio: []
203+
},
210204
'npm view'
211205
);
212206

@@ -359,9 +353,7 @@ function _installPackage(
359353
): void {
360354
try {
361355
logger.info(`Installing ${name}...`);
362-
const npmPath: string = getNpmPath();
363-
_runAsShellCommandAndConfirmSuccess(
364-
npmPath,
356+
_runNpmAsShellCommandAndConfirmSuccess(
365357
[npmCommand],
366358
{
367359
stdio: 'inherit',
@@ -385,13 +377,6 @@ function _getBinPath(packageInstallFolder: string, binName: string): string {
385377
return path.resolve(binFolderPath, resolvedBinName);
386378
}
387379

388-
/**
389-
* Returns a cross-platform path - windows must enclose any path containing spaces within double quotes.
390-
*/
391-
function _getPlatformPath(platformPath: string): string {
392-
return IS_WINDOWS && platformPath.includes(' ') ? `"${platformPath}"` : platformPath;
393-
}
394-
395380
/**
396381
* Write a flag file to the package's install directory, signifying that the install was successful.
397382
*/
@@ -407,12 +392,12 @@ function _writeFlagFile(packageInstallFolder: string): void {
407392
/**
408393
* Run the specified command under the platform's shell and throw if it didn't succeed.
409394
*/
410-
function _runAsShellCommandAndConfirmSuccess(
411-
command: string,
395+
function _runNpmAsShellCommandAndConfirmSuccess(
412396
args: string[],
413397
options: childProcess.SpawnSyncOptions,
414398
commandNameForLogging: string
415399
): childProcess.SpawnSyncReturns<string | Buffer<ArrayBufferLike>> {
400+
let command: string = getNpmPath();
416401
if (IS_WINDOWS) {
417402
({ command, args } = convertCommandAndArgsToShell({ command, args }));
418403
}
@@ -475,8 +460,8 @@ export function installAndRun(
475460
});
476461

477462
_createPackageJson(packageInstallFolder, packageName, packageVersion);
478-
const command: 'install' | 'ci' = lockFilePath ? 'ci' : 'install';
479-
_installPackage(logger, packageInstallFolder, packageName, packageVersion, command);
463+
const installCommand: 'install' | 'ci' = lockFilePath ? 'ci' : 'install';
464+
_installPackage(logger, packageInstallFolder, packageName, packageVersion, installCommand);
480465
_writeFlagFile(packageInstallFolder);
481466
}
482467

0 commit comments

Comments
 (0)