mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-20 00:04:14 +08:00
Fixing strict null checks in build util
This commit is contained in:
parent
56a161042c
commit
31e0752065
@ -20,13 +20,13 @@ function incremental(streamProvider, initial, supportsCancellation) {
|
||||
var output = es.through();
|
||||
var state = 'idle';
|
||||
var buffer = Object.create(null);
|
||||
var token = !supportsCancellation ? null : { isCancellationRequested: function () { return Object.keys(buffer).length > 0; } };
|
||||
var token = !supportsCancellation ? undefined : { isCancellationRequested: function () { return Object.keys(buffer).length > 0; } };
|
||||
var run = function (input, isCancellable) {
|
||||
state = 'running';
|
||||
var stream = !supportsCancellation ? streamProvider() : streamProvider(isCancellable ? token : NoCancellationToken);
|
||||
input
|
||||
.pipe(stream)
|
||||
.pipe(es.through(null, function () {
|
||||
.pipe(es.through(undefined, function () {
|
||||
state = 'idle';
|
||||
eventuallyRun();
|
||||
}))
|
||||
@ -119,7 +119,7 @@ function loadSourcemaps() {
|
||||
var output = input
|
||||
.pipe(es.map(function (f, cb) {
|
||||
if (f.sourceMap) {
|
||||
cb(null, f);
|
||||
cb(undefined, f);
|
||||
return;
|
||||
}
|
||||
if (!f.contents) {
|
||||
@ -128,7 +128,8 @@ function loadSourcemaps() {
|
||||
}
|
||||
var contents = f.contents.toString('utf8');
|
||||
var reg = /\/\/# sourceMappingURL=(.*)$/g;
|
||||
var lastMatch = null, match = null;
|
||||
var lastMatch = null;
|
||||
var match = null;
|
||||
while (match = reg.exec(contents)) {
|
||||
lastMatch = match;
|
||||
}
|
||||
@ -140,7 +141,7 @@ function loadSourcemaps() {
|
||||
sources: [f.relative.replace(/\//g, '/')],
|
||||
sourcesContent: [contents]
|
||||
};
|
||||
cb(null, f);
|
||||
cb(undefined, f);
|
||||
return;
|
||||
}
|
||||
f.contents = Buffer.from(contents.replace(/\/\/# sourceMappingURL=(.*)$/g, ''), 'utf8');
|
||||
@ -149,7 +150,7 @@ function loadSourcemaps() {
|
||||
return cb(err);
|
||||
}
|
||||
f.sourceMap = JSON.parse(contents);
|
||||
cb(null, f);
|
||||
cb(undefined, f);
|
||||
});
|
||||
}));
|
||||
return es.duplex(input, output);
|
||||
@ -192,7 +193,7 @@ function getVersion(root) {
|
||||
exports.getVersion = getVersion;
|
||||
function rebase(count) {
|
||||
return rename(function (f) {
|
||||
var parts = f.dirname.split(/[\/\\]/);
|
||||
var parts = f.dirname ? f.dirname.split(/[\/\\]/) : [];
|
||||
f.dirname = parts.slice(count).join(path.sep);
|
||||
});
|
||||
}
|
||||
|
||||
@ -34,7 +34,7 @@ export function incremental(streamProvider: IStreamProvider, initial: NodeJS.Rea
|
||||
let state = 'idle';
|
||||
let buffer = Object.create(null);
|
||||
|
||||
const token: ICancellationToken = !supportsCancellation ? null : { isCancellationRequested: () => Object.keys(buffer).length > 0 };
|
||||
const token: ICancellationToken | undefined = !supportsCancellation ? undefined : { isCancellationRequested: () => Object.keys(buffer).length > 0 };
|
||||
|
||||
const run = (input, isCancellable) => {
|
||||
state = 'running';
|
||||
@ -43,7 +43,7 @@ export function incremental(streamProvider: IStreamProvider, initial: NodeJS.Rea
|
||||
|
||||
input
|
||||
.pipe(stream)
|
||||
.pipe(es.through(null, () => {
|
||||
.pipe(es.through(undefined, () => {
|
||||
state = 'idle';
|
||||
eventuallyRun();
|
||||
}))
|
||||
@ -122,7 +122,7 @@ export function toFileUri(filePath: string): string {
|
||||
}
|
||||
|
||||
export function skipDirectories(): NodeJS.ReadWriteStream {
|
||||
return es.mapSync<VinylFile, VinylFile>(f => {
|
||||
return es.mapSync<VinylFile, VinylFile | undefined>(f => {
|
||||
if (!f.isDirectory()) {
|
||||
return f;
|
||||
}
|
||||
@ -157,9 +157,9 @@ export function loadSourcemaps(): NodeJS.ReadWriteStream {
|
||||
const input = es.through();
|
||||
|
||||
const output = input
|
||||
.pipe(es.map<FileSourceMap, FileSourceMap>((f, cb): FileSourceMap => {
|
||||
.pipe(es.map<FileSourceMap, FileSourceMap | undefined>((f, cb): FileSourceMap | undefined => {
|
||||
if (f.sourceMap) {
|
||||
cb(null, f);
|
||||
cb(undefined, f);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -171,7 +171,8 @@ export function loadSourcemaps(): NodeJS.ReadWriteStream {
|
||||
const contents = (<Buffer>f.contents).toString('utf8');
|
||||
|
||||
const reg = /\/\/# sourceMappingURL=(.*)$/g;
|
||||
let lastMatch = null, match = null;
|
||||
let lastMatch: RegExpMatchArray | null = null;
|
||||
let match: RegExpMatchArray | null = null;
|
||||
|
||||
while (match = reg.exec(contents)) {
|
||||
lastMatch = match;
|
||||
@ -186,7 +187,7 @@ export function loadSourcemaps(): NodeJS.ReadWriteStream {
|
||||
sourcesContent: [contents]
|
||||
};
|
||||
|
||||
cb(null, f);
|
||||
cb(undefined, f);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -196,7 +197,7 @@ export function loadSourcemaps(): NodeJS.ReadWriteStream {
|
||||
if (err) { return cb(err); }
|
||||
|
||||
f.sourceMap = JSON.parse(contents);
|
||||
cb(null, f);
|
||||
cb(undefined, f);
|
||||
});
|
||||
}));
|
||||
|
||||
@ -236,7 +237,7 @@ export function rimraf(dir: string): (cb: any) => void {
|
||||
return cb => retry(cb);
|
||||
}
|
||||
|
||||
export function getVersion(root: string): string {
|
||||
export function getVersion(root: string): string | undefined {
|
||||
let version = process.env['BUILD_SOURCEVERSION'];
|
||||
|
||||
if (!version || !/^[0-9a-f]{40}$/i.test(version)) {
|
||||
@ -248,7 +249,7 @@ export function getVersion(root: string): string {
|
||||
|
||||
export function rebase(count: number): NodeJS.ReadWriteStream {
|
||||
return rename(f => {
|
||||
const parts = f.dirname.split(/[\/\\]/);
|
||||
const parts = f.dirname ? f.dirname.split(/[\/\\]/) : [];
|
||||
f.dirname = parts.slice(count).join(path.sep);
|
||||
});
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user