From 31d115a31a60c4ae907eea5ac0f4e300e6480c79 Mon Sep 17 00:00:00 2001 From: Ian Clanton-Thuon Date: Tue, 10 Sep 2024 12:35:40 -0700 Subject: [PATCH] Update rush to 5.133.4. --- common/scripts/install-run-rush-pnpm.js | 3 ++ common/scripts/install-run-rush.js | 3 ++ common/scripts/install-run-rushx.js | 3 ++ common/scripts/install-run.js | 40 +++++++++++++++++-------- rush.json | 2 +- 5 files changed, 38 insertions(+), 13 deletions(-) diff --git a/common/scripts/install-run-rush-pnpm.js b/common/scripts/install-run-rush-pnpm.js index 72a7bfd..2356649 100644 --- a/common/scripts/install-run-rush-pnpm.js +++ b/common/scripts/install-run-rush-pnpm.js @@ -10,6 +10,9 @@ // node common/scripts/install-run-rush-pnpm.js pnpm-command // // For more information, see: https://rushjs.io/pages/maintainer/setup_new_repo/ +// +// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. +// See the @microsoft/rush package's LICENSE file for details. /******/ (() => { // webpackBootstrap /******/ "use strict"; diff --git a/common/scripts/install-run-rush.js b/common/scripts/install-run-rush.js index 008e644..9676fc7 100644 --- a/common/scripts/install-run-rush.js +++ b/common/scripts/install-run-rush.js @@ -8,6 +8,9 @@ // node common/scripts/install-run-rush.js install // // For more information, see: https://rushjs.io/pages/maintainer/setup_new_repo/ +// +// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. +// See the @microsoft/rush package's LICENSE file for details. /******/ (() => { // webpackBootstrap /******/ "use strict"; diff --git a/common/scripts/install-run-rushx.js b/common/scripts/install-run-rushx.js index 0a0235f..6581521 100644 --- a/common/scripts/install-run-rushx.js +++ b/common/scripts/install-run-rushx.js @@ -10,6 +10,9 @@ // node common/scripts/install-run-rushx.js custom-command // // For more information, see: https://rushjs.io/pages/maintainer/setup_new_repo/ +// +// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. +// See the @microsoft/rush package's LICENSE file for details. /******/ (() => { // webpackBootstrap /******/ "use strict"; diff --git a/common/scripts/install-run.js b/common/scripts/install-run.js index 08b606a..9283c44 100644 --- a/common/scripts/install-run.js +++ b/common/scripts/install-run.js @@ -8,6 +8,9 @@ // node common/scripts/install-run.js qrcode@1.2.2 qrcode https://rushjs.io // // For more information, see: https://rushjs.io/pages/maintainer/setup_new_repo/ +// +// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. +// See the @microsoft/rush package's LICENSE file for details. /******/ (() => { // webpackBootstrap /******/ "use strict"; @@ -338,7 +341,7 @@ let _npmPath = undefined; function getNpmPath() { if (!_npmPath) { try { - if (os__WEBPACK_IMPORTED_MODULE_2__.platform() === 'win32') { + if (_isWindows()) { // We're on Windows const whereOutput = child_process__WEBPACK_IMPORTED_MODULE_0__.execSync('where npm', { stdio: [] }).toString(); const lines = whereOutput.split(os__WEBPACK_IMPORTED_MODULE_2__.EOL).filter((line) => !!line); @@ -457,10 +460,13 @@ function _resolvePackageVersion(logger, rushCommonFolder, { name, version }) { // ``` // // if only a single version matches. - const npmVersionSpawnResult = child_process__WEBPACK_IMPORTED_MODULE_0__.spawnSync(npmPath, ['view', `${name}@${version}`, 'version', '--no-update-notifier', '--json'], { + const spawnSyncOptions = { cwd: rushTempFolder, - stdio: [] - }); + stdio: [], + shell: _isWindows() + }; + const platformNpmPath = _getPlatformPath(npmPath); + const npmVersionSpawnResult = child_process__WEBPACK_IMPORTED_MODULE_0__.spawnSync(platformNpmPath, ['view', `${name}@${version}`, 'version', '--no-update-notifier', '--json'], spawnSyncOptions); if (npmVersionSpawnResult.status !== 0) { throw new Error(`"npm view" returned error code ${npmVersionSpawnResult.status}`); } @@ -593,10 +599,12 @@ function _installPackage(logger, packageInstallFolder, name, version, command) { try { logger.info(`Installing ${name}...`); const npmPath = getNpmPath(); - const result = child_process__WEBPACK_IMPORTED_MODULE_0__.spawnSync(npmPath, [command], { + const platformNpmPath = _getPlatformPath(npmPath); + const result = child_process__WEBPACK_IMPORTED_MODULE_0__.spawnSync(platformNpmPath, [command], { stdio: 'inherit', cwd: packageInstallFolder, - env: process.env + env: process.env, + shell: _isWindows() }); if (result.status !== 0) { throw new Error(`"npm ${command}" encountered an error`); @@ -612,9 +620,18 @@ function _installPackage(logger, packageInstallFolder, name, version, command) { */ function _getBinPath(packageInstallFolder, binName) { const binFolderPath = path__WEBPACK_IMPORTED_MODULE_3__.resolve(packageInstallFolder, NODE_MODULES_FOLDER_NAME, '.bin'); - const resolvedBinName = os__WEBPACK_IMPORTED_MODULE_2__.platform() === 'win32' ? `${binName}.cmd` : binName; + const resolvedBinName = _isWindows() ? `${binName}.cmd` : binName; return path__WEBPACK_IMPORTED_MODULE_3__.resolve(binFolderPath, resolvedBinName); } +/** + * Returns a cross-platform path - windows must enclose any path containing spaces within double quotes. + */ +function _getPlatformPath(platformPath) { + return _isWindows() && platformPath.includes(' ') ? `"${platformPath}"` : platformPath; +} +function _isWindows() { + return os__WEBPACK_IMPORTED_MODULE_2__.platform() === 'win32'; +} /** * Write a flag file to the package's install directory, signifying that the install was successful. */ @@ -656,15 +673,14 @@ function installAndRun(logger, packageName, packageVersion, packageBinName, pack const originalEnvPath = process.env.PATH || ''; let result; try { - // Node.js on Windows can not spawn a file when the path has a space on it - // unless the path gets wrapped in a cmd friendly way and shell mode is used - const shouldUseShell = binPath.includes(' ') && os__WEBPACK_IMPORTED_MODULE_2__.platform() === 'win32'; - const platformBinPath = shouldUseShell ? `"${binPath}"` : binPath; + // `npm` bin stubs on Windows are `.cmd` files + // Node.js will not directly invoke a `.cmd` file unless `shell` is set to `true` + const platformBinPath = _getPlatformPath(binPath); process.env.PATH = [binFolderPath, originalEnvPath].join(path__WEBPACK_IMPORTED_MODULE_3__.delimiter); result = child_process__WEBPACK_IMPORTED_MODULE_0__.spawnSync(platformBinPath, packageBinArgs, { stdio: 'inherit', windowsVerbatimArguments: false, - shell: shouldUseShell, + shell: _isWindows(), cwd: process.cwd(), env: process.env }); diff --git a/rush.json b/rush.json index a623986..68aee61 100644 --- a/rush.json +++ b/rush.json @@ -16,7 +16,7 @@ * path segment in the "$schema" field for all your Rush config files. This will ensure * correct error-underlining and tab-completion for editors such as VS Code. */ - "rushVersion": "5.118.4", + "rushVersion": "5.133.4", /** * The next field selects which package manager should be installed and determines its version.