mirror of
https://github.com/microsoft/vscode.git
synced 2026-02-15 07:28:05 +00:00
refactor: replace gulp-untar with custom untar implementation and update dependencies (#288081)
This commit is contained in:
@@ -13,9 +13,8 @@ import { tmpdir } from 'os';
|
||||
import { existsSync, mkdirSync, rmSync } from 'fs';
|
||||
import * as task from './lib/task.ts';
|
||||
import watcher from './lib/watch/index.ts';
|
||||
import { debounce } from './lib/util.ts';
|
||||
import { debounce, untar } from './lib/util.ts';
|
||||
import { createReporter } from './lib/reporter.ts';
|
||||
import untar from 'gulp-untar';
|
||||
import gunzip from 'gulp-gunzip';
|
||||
|
||||
const root = 'cli';
|
||||
|
||||
@@ -21,7 +21,7 @@ import vfs from 'vinyl-fs';
|
||||
import packageJson from '../package.json' with { type: 'json' };
|
||||
import flatmap from 'gulp-flatmap';
|
||||
import gunzip from 'gulp-gunzip';
|
||||
import untar from 'gulp-untar';
|
||||
import { untar } from './lib/util.ts';
|
||||
import File from 'vinyl';
|
||||
import * as fs from 'fs';
|
||||
import glob from 'glob';
|
||||
|
||||
12
build/lib/typings/gulp-untar.d.ts
vendored
12
build/lib/typings/gulp-untar.d.ts
vendored
@@ -1,12 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
declare module 'gulp-untar' {
|
||||
import type { Transform } from 'stream';
|
||||
|
||||
function untar(): Transform;
|
||||
|
||||
export = untar;
|
||||
}
|
||||
@@ -15,6 +15,8 @@ import through from 'through';
|
||||
import sm from 'source-map';
|
||||
import { pathToFileURL } from 'url';
|
||||
import ternaryStream from 'ternary-stream';
|
||||
import type { Transform } from 'stream';
|
||||
import * as tar from 'tar';
|
||||
|
||||
const root = path.dirname(path.dirname(import.meta.dirname));
|
||||
|
||||
@@ -429,3 +431,39 @@ export class VinylStat implements fs.Stats {
|
||||
isFIFO(): boolean { return false; }
|
||||
isSocket(): boolean { return false; }
|
||||
}
|
||||
|
||||
export function untar(): Transform {
|
||||
return es.through(function (this: through.ThroughStream, f: VinylFile) {
|
||||
if (!f.contents || !Buffer.isBuffer(f.contents)) {
|
||||
this.emit('error', new Error('Expected file with Buffer contents'));
|
||||
return;
|
||||
}
|
||||
|
||||
const self = this;
|
||||
const parser = new tar.Parser();
|
||||
|
||||
parser.on('entry', (entry: tar.ReadEntry) => {
|
||||
if (entry.type === 'File') {
|
||||
const chunks: Buffer[] = [];
|
||||
entry.on('data', (chunk: Buffer) => chunks.push(chunk));
|
||||
entry.on('end', () => {
|
||||
const file = new VinylFile({
|
||||
path: entry.path,
|
||||
contents: Buffer.concat(chunks),
|
||||
stat: new VinylStat({
|
||||
mode: entry.mode,
|
||||
mtime: entry.mtime,
|
||||
size: entry.size
|
||||
})
|
||||
});
|
||||
self.emit('data', file);
|
||||
});
|
||||
} else {
|
||||
entry.resume();
|
||||
}
|
||||
});
|
||||
|
||||
parser.on('error', (err: Error) => self.emit('error', err));
|
||||
parser.end(f.contents);
|
||||
}) as Transform;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user