Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/build/lib/date.ts
3520 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
import path from 'path';
7
import fs from 'fs';
8
9
const root = path.join(__dirname, '..', '..');
10
11
/**
12
* Writes a `outDir/date` file with the contents of the build
13
* so that other tasks during the build process can use it and
14
* all use the same date.
15
*/
16
export function writeISODate(outDir: string) {
17
const result = () => new Promise<void>((resolve, _) => {
18
const outDirectory = path.join(root, outDir);
19
fs.mkdirSync(outDirectory, { recursive: true });
20
21
const date = new Date().toISOString();
22
fs.writeFileSync(path.join(outDirectory, 'date'), date, 'utf8');
23
24
resolve();
25
});
26
result.taskName = 'build-date-file';
27
return result;
28
}
29
30
export function readISODate(outDir: string): string {
31
const outDirectory = path.join(root, outDir);
32
return fs.readFileSync(path.join(outDirectory, 'date'), 'utf8');
33
}
34
35