mirror of
https://github.com/microsoft/vscode.git
synced 2026-02-14 23:18:36 +00:00
Fix date reading logic in build scripts to handle missing files gracefully
This commit is contained in:
@@ -321,7 +321,7 @@ function packageTask(type: string, platform: string, arch: string, sourceFolderN
|
|||||||
|
|
||||||
let productJsonContents = '';
|
let productJsonContents = '';
|
||||||
const productJsonStream = gulp.src(['product.json'], { base: '.' })
|
const productJsonStream = gulp.src(['product.json'], { base: '.' })
|
||||||
.pipe(jsonEditor({ commit, date: readISODate('out-build'), version }))
|
.pipe(jsonEditor({ commit, date: readISODate(sourceFolderName), version }))
|
||||||
.pipe(es.through(function (file) {
|
.pipe(es.through(function (file) {
|
||||||
productJsonContents = file.contents.toString();
|
productJsonContents = file.contents.toString();
|
||||||
this.emit('data', file);
|
this.emit('data', file);
|
||||||
|
|||||||
@@ -370,7 +370,7 @@ function packageTask(platform: string, arch: string, sourceFolderName: string, d
|
|||||||
|
|
||||||
let productJsonContents: string;
|
let productJsonContents: string;
|
||||||
const productJsonStream = gulp.src(['product.json'], { base: '.' })
|
const productJsonStream = gulp.src(['product.json'], { base: '.' })
|
||||||
.pipe(jsonEditor({ commit, date: readISODate('out-build'), checksums, version }))
|
.pipe(jsonEditor({ commit, date: readISODate(out), checksums, version }))
|
||||||
.pipe(es.through(function (file) {
|
.pipe(es.through(function (file) {
|
||||||
productJsonContents = file.contents.toString();
|
productJsonContents = file.contents.toString();
|
||||||
this.emit('data', file);
|
this.emit('data', file);
|
||||||
|
|||||||
@@ -29,5 +29,13 @@ export function writeISODate(outDir: string) {
|
|||||||
|
|
||||||
export function readISODate(outDir: string): string {
|
export function readISODate(outDir: string): string {
|
||||||
const outDirectory = path.join(root, outDir);
|
const outDirectory = path.join(root, outDir);
|
||||||
return fs.readFileSync(path.join(outDirectory, 'date'), 'utf8');
|
try {
|
||||||
|
return fs.readFileSync(path.join(outDirectory, 'date'), 'utf8');
|
||||||
|
} catch {
|
||||||
|
// Fallback to out-build (old build writes date there, esbuild writes to bundle output dir)
|
||||||
|
if (outDir !== 'out-build') {
|
||||||
|
return fs.readFileSync(path.join(root, 'out-build', 'date'), 'utf8');
|
||||||
|
}
|
||||||
|
throw new Error(`Could not find date file in ${outDir}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user