Merge from vscode c58aaab8a1cc22a7139b761166a0d4f37d41e998 (#7880)

* Merge from vscode c58aaab8a1cc22a7139b761166a0d4f37d41e998

* fix pipelines

* fix strict-null-checks

* add missing files
This commit is contained in:
Anthony Dresser
2019-10-21 22:12:22 -07:00
committed by GitHub
parent 7c9be74970
commit 1e22f47304
913 changed files with 18898 additions and 16536 deletions

View File

@@ -122,7 +122,11 @@ export function toDecodeStream(readable: Readable, options: IDecodeStreamOptions
// detection. thus, wrap up starting the stream even
// without all the data to get things going
else {
this._startDecodeStream(() => this.decodeStream!.end(callback));
this._startDecodeStream(() => {
if (this.decodeStream) {
this.decodeStream.end(callback);
}
});
}
}
};

View File

@@ -9,6 +9,7 @@ export interface NLSConfiguration {
[key: string]: string;
};
pseudo?: boolean;
_languagePackSupport?: boolean;
}
export interface InternalNLSConfiguration extends NLSConfiguration {

View File

@@ -11,21 +11,15 @@ const cmdline = {
unix: '/sbin/ifconfig -a || /sbin/ip link'
};
const invalidMacAddresses = [
const invalidMacAddresses = new Set([
'00:00:00:00:00:00',
'ff:ff:ff:ff:ff:ff',
'ac:de:48:00:11:22'
];
]);
function validateMacAddress(candidate: string): boolean {
let tempCandidate = candidate.replace(/\-/g, ':').toLowerCase();
for (let invalidMacAddress of invalidMacAddresses) {
if (invalidMacAddress === tempCandidate) {
return false;
}
}
return true;
const tempCandidate = candidate.replace(/\-/g, ':').toLowerCase();
return !invalidMacAddresses.has(tempCandidate);
}
export function getMac(): Promise<string> {
@@ -66,4 +60,4 @@ function doGetMac(): Promise<string> {
reject(err);
}
});
}
}

View File

@@ -138,6 +138,20 @@ export async function readdir(path: string): Promise<string[]> {
return handleDirectoryChildren(await promisify(fs.readdir)(path));
}
export async function readdirWithFileTypes(path: string): Promise<fs.Dirent[]> {
const children = await promisify(fs.readdir)(path, { withFileTypes: true });
// Mac: uses NFD unicode form on disk, but we want NFC
// See also https://github.com/nodejs/node/issues/2165
if (platform.isMacintosh) {
for (const child of children) {
child.name = normalizeNFC(child.name);
}
}
return children;
}
export function readdirSync(path: string): string[] {
return handleDirectoryChildren(fs.readdirSync(path));
}
@@ -679,4 +693,4 @@ const WIN32_MAX_HEAP_SIZE = 700 * 1024 * 1024; // 700 MB
const GENERAL_MAX_HEAP_SIZE = 700 * 2 * 1024 * 1024; // 1400 MB
export const MAX_FILE_SIZE = process.arch === 'ia32' ? WIN32_MAX_FILE_SIZE : GENERAL_MAX_FILE_SIZE;
export const MAX_HEAP_SIZE = process.arch === 'ia32' ? WIN32_MAX_HEAP_SIZE : GENERAL_MAX_HEAP_SIZE;
export const MAX_HEAP_SIZE = process.arch === 'ia32' ? WIN32_MAX_HEAP_SIZE : GENERAL_MAX_HEAP_SIZE;

View File

@@ -40,7 +40,7 @@ function getWindowsCode(status: number): TerminateResponseCode {
}
}
export function terminateProcess(process: cp.ChildProcess, cwd?: string): TerminateResponse {
function terminateProcess(process: cp.ChildProcess, cwd?: string): Promise<TerminateResponse> {
if (Platform.isWindows) {
try {
const options: any = {
@@ -49,24 +49,41 @@ export function terminateProcess(process: cp.ChildProcess, cwd?: string): Termin
if (cwd) {
options.cwd = cwd;
}
cp.execFileSync('taskkill', ['/T', '/F', '/PID', process.pid.toString()], options);
const killProcess = cp.execFile('taskkill', ['/T', '/F', '/PID', process.pid.toString()], options);
return new Promise((resolve, reject) => {
killProcess.once('error', (err) => {
resolve({ success: false, error: err });
});
killProcess.once('exit', (code, signal) => {
if (code === 0) {
resolve({ success: true });
} else {
resolve({ success: false, code: code !== null ? code : TerminateResponseCode.Unknown });
}
});
});
} catch (err) {
return { success: false, error: err, code: err.status ? getWindowsCode(err.status) : TerminateResponseCode.Unknown };
return Promise.resolve({ success: false, error: err, code: err.status ? getWindowsCode(err.status) : TerminateResponseCode.Unknown });
}
} else if (Platform.isLinux || Platform.isMacintosh) {
try {
const cmd = getPathFromAmdModule(require, 'vs/base/node/terminateProcess.sh');
const result = cp.spawnSync(cmd, [process.pid.toString()]);
if (result.error) {
return { success: false, error: result.error };
}
return new Promise((resolve, reject) => {
cp.execFile(cmd, [process.pid.toString()], { encoding: 'utf8', shell: true } as cp.ExecFileOptions, (err, stdout, stderr) => {
if (err) {
resolve({ success: false, error: err });
} else {
resolve({ success: true });
}
});
});
} catch (err) {
return { success: false, error: err };
return Promise.resolve({ success: false, error: err });
}
} else {
process.kill('SIGKILL');
}
return { success: true };
return Promise.resolve({ success: true });
}
export function getWindowsShell(): string {
@@ -122,6 +139,7 @@ export abstract class AbstractProcess<TProgressData> {
}
this.childProcess = null;
this.childProcessPromise = null;
this.terminateRequested = false;
if (this.options.env) {
@@ -288,11 +306,12 @@ export abstract class AbstractProcess<TProgressData> {
}
return this.childProcessPromise.then((childProcess) => {
this.terminateRequested = true;
const result = terminateProcess(childProcess, this.options.cwd);
if (result.success) {
this.childProcess = null;
}
return result;
return terminateProcess(childProcess, this.options.cwd).then(response => {
if (response.success) {
this.childProcess = null;
}
return response;
});
}, (err) => {
return { success: true };
});
@@ -316,13 +335,16 @@ export abstract class AbstractProcess<TProgressData> {
export class LineProcess extends AbstractProcess<LineData> {
private stdoutLineDecoder: LineDecoder;
private stderrLineDecoder: LineDecoder;
private stdoutLineDecoder: LineDecoder | null;
private stderrLineDecoder: LineDecoder | null;
public constructor(executable: Executable);
public constructor(cmd: string, args: string[], shell: boolean, options: CommandOptions);
public constructor(arg1: string | Executable, arg2?: string[], arg3?: boolean | ForkOptions, arg4?: CommandOptions) {
super(<any>arg1, arg2, <any>arg3, arg4);
this.stdoutLineDecoder = null;
this.stderrLineDecoder = null;
}
protected handleExec(cc: ValueCallback<SuccessData>, pp: ProgressCallback<LineData>, error: Error, stdout: Buffer, stderr: Buffer) {
@@ -341,24 +363,30 @@ export class LineProcess extends AbstractProcess<LineData> {
}
protected handleSpawn(childProcess: cp.ChildProcess, cc: ValueCallback<SuccessData>, pp: ProgressCallback<LineData>, ee: ErrorCallback, sync: boolean): void {
this.stdoutLineDecoder = new LineDecoder();
this.stderrLineDecoder = new LineDecoder();
const stdoutLineDecoder = new LineDecoder();
const stderrLineDecoder = new LineDecoder();
childProcess.stdout.on('data', (data: Buffer) => {
const lines = this.stdoutLineDecoder.write(data);
const lines = stdoutLineDecoder.write(data);
lines.forEach(line => pp({ line: line, source: Source.stdout }));
});
childProcess.stderr.on('data', (data: Buffer) => {
const lines = this.stderrLineDecoder.write(data);
const lines = stderrLineDecoder.write(data);
lines.forEach(line => pp({ line: line, source: Source.stderr }));
});
this.stdoutLineDecoder = stdoutLineDecoder;
this.stderrLineDecoder = stderrLineDecoder;
}
protected handleClose(data: any, cc: ValueCallback<SuccessData>, pp: ProgressCallback<LineData>, ee: ErrorCallback): void {
[this.stdoutLineDecoder.end(), this.stderrLineDecoder.end()].forEach((line, index) => {
if (line) {
pp({ line: line, source: index === 0 ? Source.stdout : Source.stderr });
}
});
const stdoutLine = this.stdoutLineDecoder ? this.stdoutLineDecoder.end() : null;
if (stdoutLine) {
pp({ line: stdoutLine, source: Source.stdout });
}
const stderrLine = this.stderrLineDecoder ? this.stderrLineDecoder.end() : null;
if (stderrLine) {
pp({ line: stderrLine, source: Source.stderr });
}
}
}

View File

@@ -156,7 +156,7 @@ function extractZip(zipfile: ZipFile, targetPath: string, options: IOptions, tok
const stream = openZipStream(zipfile, entry);
const mode = modeFromEntry(entry);
last = createCancelablePromise(token => throttler.queue(() => stream.then(stream => extractEntry(stream, fileName, mode, targetPath, options, token).then(() => readNextEntry(token)))).then(null!, e));
last = createCancelablePromise(token => throttler.queue(() => stream.then(stream => extractEntry(stream, fileName, mode, targetPath, options, token).then(() => readNextEntry(token)))).then(null, e));
});
});
}