Socket
Socket
Sign inDemoInstall

@vscode/test-electron

Package Overview
Dependencies
Maintainers
7
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vscode/test-electron - npm Package Compare versions

Comparing version 2.3.0 to 2.3.2

killTree.sh

8

CHANGELOG.md
# Changelog
### 2.3.2 | 2022-05-11
- Fix download method not working for the vscode cli.
### 2.3.1 | 2022-04-04
- Gracefully kill VS Code if SIGINT is received
### 2.3.0 | 2022-02-27

@@ -4,0 +12,0 @@

10

out/download.js

@@ -187,3 +187,3 @@ "use strict";

*/
async function unzipVSCode(reporter, extractDir, extractSync, stream, format) {
async function unzipVSCode(reporter, extractDir, stream, platform, format) {
const stagingFile = path.join(os_1.tmpdir(), `vscode-test-${Date.now()}.zip`);

@@ -231,3 +231,5 @@ if (format === 'zip') {

}
await spawnDecompressorChild('tar', ['-xzf', '-', '--strip-components=1', '-C', extractDir], stream);
// The CLI is a singular binary that doesn't have a wrapper component to remove
const s = platform.includes('cli-') ? 0 : 1;
await spawnDecompressorChild('tar', ['-xzf', '-', `--strip-components=${s}`, '-C', extractDir], stream);
}

@@ -255,3 +257,3 @@ }

let version = options === null || options === void 0 ? void 0 : options.version;
const { platform = util_2.systemDefaultPlatform, cachePath = exports.defaultCachePath, reporter = new progress_1.ConsoleReporter(process.stdout.isTTY), extractSync = false, timeout = 15000, } = options;
const { platform = util_2.systemDefaultPlatform, cachePath = exports.defaultCachePath, reporter = new progress_1.ConsoleReporter(process.stdout.isTTY), timeout = 15000, } = options;
if (version === 'stable') {

@@ -333,3 +335,3 @@ version = await fetchTargetStableVersion({ timeout, cachePath, platform });

// to start consuming the stream immediately.
await unzipVSCode(reporter, downloadStaging, extractSync, stream, format);
await unzipVSCode(reporter, downloadStaging, stream, platform, format);
await fs.promises.rename(downloadStaging, downloadedPath);

@@ -336,0 +338,0 @@ reporter.report({ stage: progress_1.ProgressReportStage.NewInstallComplete, downloadedPath });

2

out/runTest.d.ts

@@ -62,2 +62,4 @@ import { DownloadVersion, DownloadPlatform } from './download';

*
* The first argument is the path to the file specified in `extensionTestsPath`.
*
*/

@@ -64,0 +66,0 @@ extensionTestsPath: string;

@@ -11,2 +11,3 @@ "use strict";

const download_1 = require("./download");
const util_1 = require("./util");
/**

@@ -61,6 +62,24 @@ * Run VS Code extension test

}
const SIGINT = 'SIGINT';
async function innerRunTests(executable, args, testRunnerEnv) {
return new Promise((resolve, reject) => {
const fullEnv = Object.assign({}, process.env, testRunnerEnv);
const cmd = cp.spawn(executable, args, { env: fullEnv });
const fullEnv = Object.assign({}, process.env, testRunnerEnv);
const cmd = cp.spawn(executable, args, { env: fullEnv });
let exitRequested = false;
const ctrlc1 = () => {
process.removeListener(SIGINT, ctrlc1);
process.on(SIGINT, ctrlc2);
console.log('Closing VS Code gracefully. Press Ctrl+C to force close.');
exitRequested = true;
cmd.kill(SIGINT); // this should cause the returned promise to resolve
};
const ctrlc2 = () => {
console.log('Closing VS Code forcefully.');
process.removeListener(SIGINT, ctrlc2);
exitRequested = true;
util_1.killTree(cmd.pid, true);
};
const prom = new Promise((resolve, reject) => {
if (cmd.pid) {
process.on(SIGINT, ctrlc1);
}
cmd.stdout.on('data', (d) => process.stdout.write(d));

@@ -96,2 +115,15 @@ cmd.stderr.on('data', (d) => process.stderr.write(d));

});
let code;
try {
code = await prom;
}
finally {
process.removeListener(SIGINT, ctrlc1);
process.removeListener(SIGINT, ctrlc2);
}
// exit immediately if we handled a SIGINT and no one else did
if (exitRequested && process.listenerCount(SIGINT) === 0) {
process.exit(1);
}
return code;
}

@@ -63,1 +63,2 @@ /// <reference types="node" />

export declare function onceWithoutRejections<T, Args extends unknown[]>(fn: (...args: Args) => Promise<T>): (...args: Args) => Promise<T>;
export declare function killTree(processId: number, force: boolean): Promise<void>;

@@ -7,9 +7,10 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.onceWithoutRejections = exports.isSubdirectory = exports.streamToBuffer = exports.isDefined = exports.resolveCliArgsFromVSCodeExecutablePath = exports.resolveCliPathFromVSCodeExecutablePath = exports.getLatestInsidersMetadata = exports.getInsidersVersionMetadata = exports.insidersDownloadDirMetadata = exports.insidersDownloadDirToExecutablePath = exports.downloadDirToExecutablePath = exports.urlToOptions = exports.getVSCodeDownloadUrl = exports.isStableVersionIdentifier = exports.isInsiderVersionIdentifier = exports.systemDefaultPlatform = void 0;
exports.killTree = exports.onceWithoutRejections = exports.isSubdirectory = exports.streamToBuffer = exports.isDefined = exports.resolveCliArgsFromVSCodeExecutablePath = exports.resolveCliPathFromVSCodeExecutablePath = exports.getLatestInsidersMetadata = exports.getInsidersVersionMetadata = exports.insidersDownloadDirMetadata = exports.insidersDownloadDirToExecutablePath = exports.downloadDirToExecutablePath = exports.urlToOptions = exports.getVSCodeDownloadUrl = exports.isStableVersionIdentifier = exports.isInsiderVersionIdentifier = exports.systemDefaultPlatform = void 0;
const child_process_1 = require("child_process");
const fs_1 = require("fs");
const createHttpProxyAgent = require("http-proxy-agent");
const createHttpsProxyAgent = require("https-proxy-agent");
const path = require("path");
const url_1 = require("url");
const request = require("./request");
const createHttpsProxyAgent = require("https-proxy-agent");
const createHttpProxyAgent = require("http-proxy-agent");
const fs_1 = require("fs");
const runTest_1 = require("./runTest");

@@ -224,1 +225,27 @@ const windowsPlatforms = new Set(['win32-archive', 'win32-x64-archive', 'win32-arm64-archive']);

exports.onceWithoutRejections = onceWithoutRejections;
function killTree(processId, force) {
let cp;
if (process.platform === 'win32') {
const windir = process.env['WINDIR'] || 'C:\\Windows';
// when killing a process in Windows its child processes are *not* killed but become root processes.
// Therefore we use TASKKILL.EXE
cp = child_process_1.spawn(path.join(windir, 'System32', 'taskkill.exe'), [
...force ? ['/F'] : [],
'/T',
'/PID',
processId.toString(),
], { stdio: 'inherit' });
}
else {
// on linux and OS X we kill all direct and indirect child processes as well
cp = child_process_1.spawn('sh', [
path.resolve(__dirname, '../killTree.sh'),
processId.toString(),
force ? '9' : '15',
], { stdio: 'inherit' });
}
return new Promise((resolve, reject) => {
cp.on('error', reject).on('exit', resolve);
});
}
exports.killTree = killTree;
{
"name": "@vscode/test-electron",
"version": "2.3.0",
"version": "2.3.2",
"scripts": {
"compile": "tsc -p ./",
"watch": "tsc -w -p ./",
"prepublish": "tsc -p ./",
"prepack": "tsc -p ./",
"fmt": "prettier --write \"lib/**/*.ts\" \"*.md\"",

@@ -9,0 +9,0 @@ "test": "eslint lib --ext ts && vitest && tsc --noEmit",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc