mirror of
https://github.com/microsoft/vscode.git
synced 2026-02-14 23:18:36 +00:00
Cleanup tsgo compile
This commit is contained in:
@@ -166,7 +166,7 @@ const tasks = compilations.map(function (tsconfigFile) {
|
||||
const compileTask = task.define(`compile-extension:${name}`, task.series(cleanTask, async () => {
|
||||
const nonts = gulp.src(src, srcOpts).pipe(filter(['**', '!**/*.ts'], { dot: true }));
|
||||
const copyNonTs = util.streamToPromise(nonts.pipe(gulp.dest(out)));
|
||||
const tsgo = spawnTsgo(absolutePath, () => rewriteTsgoSourceMappingUrlsIfNeeded(false, out, baseUrl));
|
||||
const tsgo = spawnTsgo(absolutePath, { reporterId: 'extensions' }, () => rewriteTsgoSourceMappingUrlsIfNeeded(false, out, baseUrl));
|
||||
|
||||
await Promise.all([copyNonTs, tsgo]);
|
||||
}));
|
||||
@@ -175,7 +175,7 @@ const tasks = compilations.map(function (tsconfigFile) {
|
||||
const nonts = gulp.src(src, srcOpts).pipe(filter(['**', '!**/*.ts'], { dot: true }));
|
||||
const watchInput = watcher(src, { ...srcOpts, ...{ readDelay: 200 } });
|
||||
const watchNonTs = watchInput.pipe(filter(['**', '!**/*.ts'], { dot: true })).pipe(gulp.dest(out));
|
||||
const tsgoStream = watchInput.pipe(util.debounce(() => createTsgoStream(absolutePath, () => rewriteTsgoSourceMappingUrlsIfNeeded(false, out, baseUrl)), 200));
|
||||
const tsgoStream = watchInput.pipe(util.debounce(() => createTsgoStream(absolutePath, { reporterId: 'extensions' }, () => rewriteTsgoSourceMappingUrlsIfNeeded(false, out, baseUrl)), 200));
|
||||
const watchStream = es.merge(nonts.pipe(gulp.dest(out)), watchNonTs, tsgoStream);
|
||||
|
||||
return watchStream;
|
||||
|
||||
@@ -12,8 +12,8 @@ const root = path.dirname(path.dirname(import.meta.dirname));
|
||||
const npx = process.platform === 'win32' ? 'npx.cmd' : 'npx';
|
||||
const ansiRegex = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g;
|
||||
|
||||
export function spawnTsgo(projectPath: string, onComplete?: () => Promise<void> | void): Promise<void> {
|
||||
const reporter = createReporter('extensions');
|
||||
export function spawnTsgo(projectPath: string, config: { reporterId: string }, onComplete?: () => Promise<void> | void): Promise<void> {
|
||||
const reporter = createReporter(config.reporterId);
|
||||
let report: NodeJS.ReadWriteStream | undefined;
|
||||
|
||||
const beginReport = (emitError: boolean) => {
|
||||
@@ -31,10 +31,9 @@ export function spawnTsgo(projectPath: string, onComplete?: () => Promise<void>
|
||||
report = undefined;
|
||||
};
|
||||
|
||||
const args = ['tsgo', '--project', projectPath, '--pretty', 'false', '--sourceMap', '--inlineSources'];
|
||||
|
||||
beginReport(false);
|
||||
|
||||
const args = ['tsgo', '--project', projectPath, '--pretty', 'false', '--sourceMap', '--inlineSources'];
|
||||
const child = cp.spawn(npx, args, {
|
||||
cwd: root,
|
||||
stdio: ['ignore', 'pipe', 'pipe'],
|
||||
@@ -79,7 +78,7 @@ export function spawnTsgo(projectPath: string, onComplete?: () => Promise<void>
|
||||
child.stdout?.on('data', handleData);
|
||||
child.stderr?.on('data', handleData);
|
||||
|
||||
const done = new Promise<void>((resolve, reject) => {
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
child.on('exit', code => {
|
||||
if (buffer.trim()) {
|
||||
handleLine(buffer);
|
||||
@@ -88,23 +87,22 @@ export function spawnTsgo(projectPath: string, onComplete?: () => Promise<void>
|
||||
endReport();
|
||||
if (code === 0) {
|
||||
Promise.resolve(onComplete?.()).then(() => resolve(), reject);
|
||||
return;
|
||||
} else {
|
||||
reject(new Error(`tsgo exited with code ${code ?? 'unknown'}`));
|
||||
}
|
||||
reject(new Error(`tsgo exited with code ${code ?? 'unknown'}`));
|
||||
});
|
||||
|
||||
child.on('error', err => {
|
||||
endReport();
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
|
||||
return done;
|
||||
}
|
||||
|
||||
export function createTsgoStream(projectPath: string, onComplete?: () => Promise<void> | void): NodeJS.ReadWriteStream {
|
||||
export function createTsgoStream(projectPath: string, config: { reporterId: string }, onComplete?: () => Promise<void> | void): NodeJS.ReadWriteStream {
|
||||
const stream = es.through();
|
||||
|
||||
spawnTsgo(projectPath, onComplete).then(() => {
|
||||
spawnTsgo(projectPath, config, onComplete).then(() => {
|
||||
stream.emit('end');
|
||||
}).catch(() => {
|
||||
// Errors are already reported by spawnTsgo via the reporter.
|
||||
|
||||
Reference in New Issue
Block a user