mirror of
https://github.com/microsoft/vscode.git
synced 2026-02-15 07:28:05 +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 = '';
|
||||
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) {
|
||||
productJsonContents = file.contents.toString();
|
||||
this.emit('data', file);
|
||||
|
||||
@@ -370,7 +370,7 @@ function packageTask(platform: string, arch: string, sourceFolderName: string, d
|
||||
|
||||
let productJsonContents: string;
|
||||
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) {
|
||||
productJsonContents = file.contents.toString();
|
||||
this.emit('data', file);
|
||||
|
||||
@@ -29,5 +29,13 @@ export function writeISODate(outDir: string) {
|
||||
|
||||
export function readISODate(outDir: string): string {
|
||||
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