fix: quote path to prevent space issue (#11733)

Co-authored-by: Xiaoxing Ye <xiaoye@microsoft.com>
This commit is contained in:
Xiaoxing Ye 2022-01-30 01:56:58 +08:00 committed by GitHub
parent 5635e840f8
commit a35c249fdc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 10 deletions

View file

@ -647,7 +647,7 @@ export class Registry {
if (code !== 0)
throw new Error(`Failed to install ${channel}`);
} else {
const { command, args, elevatedPermissions } = await transformCommandsForRoot([`bash ${path.join(BIN_PATH, scriptName)} ${scriptArgs.join('')}`]);
const { command, args, elevatedPermissions } = await transformCommandsForRoot([`bash "${path.join(BIN_PATH, scriptName)}" ${scriptArgs.join('')}`]);
if (elevatedPermissions)
console.log('Switching to root user to install dependencies...'); // eslint-disable-line no-console
const { code } = await spawnAsync(command, args, { cwd, stdio: 'inherit' });

View file

@ -69,6 +69,14 @@ function filePath(relative) {
return path.join(ROOT, ...relative.split('/'));
}
/**
* @param {string} path
* @returns {string}
*/
function quotePath(path) {
return "\"" + path + "\"";
}
async function runWatch() {
function runOnChanges(paths, mustExist = [], nodeFile) {
nodeFile = filePath(nodeFile);
@ -172,7 +180,7 @@ const webPackFiles = [
for (const file of webPackFiles) {
steps.push({
command: 'npx',
args: ['webpack', '--config', filePath(file), ...(watchMode ? ['--watch', '--stats', 'none'] : [])],
args: ['webpack', '--config', quotePath(filePath(file)), ...(watchMode ? ['--watch', '--stats', 'none'] : [])],
shell: true,
env: {
NODE_ENV: watchMode ? 'development' : 'production'
@ -190,9 +198,9 @@ for (const packageDir of packages) {
'babel',
...(watchMode ? ['-w', '--source-maps'] : []),
'--extensions', '.ts',
'--out-dir', path.join(packageDir, 'lib'),
'--out-dir', quotePath(path.join(packageDir, 'lib')),
'--ignore', '"packages/playwright-core/src/server/injected/**/*"',
path.join(packageDir, 'src')],
quotePath(path.join(packageDir, 'src'))],
shell: true,
});
}
@ -263,7 +271,7 @@ if (lintMode) {
// Run TypeScript for type chekcing.
steps.push({
command: 'npx',
args: ['tsc', ...(watchMode ? ['-w'] : []), '-p', filePath('.')],
args: ['tsc', ...(watchMode ? ['-w'] : []), '-p', quotePath(filePath('.'))],
shell: true,
});
}