Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions scripts/verify-vsix.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* Usage: node scripts/verify-vsix.mjs [path-to.vsix]
*/

import { execSync } from 'node:child_process';
import { execFileSync } from 'node:child_process';
import { copyFileSync, existsSync, mkdirSync, readdirSync, readFileSync, rmSync } from 'node:fs';
import { join, resolve } from 'node:path';
import { fileURLToPath } from 'node:url';
Expand Down Expand Up @@ -98,11 +98,18 @@ function extract(vsixPath) {
// POSIX use unzip. Relative paths avoid bsdtar misparsing `C:\…` as a remote.
const localCopy = join(extractDir, 'package.vsix.zip');
copyFileSync(vsixPath, localCopy);
const command =
// Spawned with an argv array rather than a shell string, so the archiver's path
// is an argument instead of a word to be parsed. `SystemRoot` is a trusted value
// — anyone who can set it can already run anything — but as argv there is no
// quoting to get right and no shell to get it wrong.
const [command, args] =
process.platform === 'win32'
? `"${join(process.env.SystemRoot ?? 'C:\\Windows', 'System32', 'tar.exe')}" -xf package.vsix.zip`
: 'unzip -q package.vsix.zip';
execSync(command, { cwd: extractDir, stdio: 'inherit' });
? [
join(process.env.SystemRoot ?? 'C:\\Windows', 'System32', 'tar.exe'),
['-xf', 'package.vsix.zip'],
]
: ['unzip', ['-q', 'package.vsix.zip']];
execFileSync(command, args, { cwd: extractDir, stdio: 'inherit' });
rmSync(localCopy);
}

Expand Down