Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/test/automation/tools/copy-driver-definition.js
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
//@ts-check
7
'use strict';
8
9
const fs = require('fs');
10
const path = require('path');
11
12
const root = path.dirname(path.dirname(path.dirname(__dirname)));
13
const driverPath = path.join(root, 'src/vs/workbench/services/driver/common/driver.ts');
14
15
let contents = fs.readFileSync(driverPath, 'utf8');
16
contents = /\/\/\*START([\s\S]*)\/\/\*END/mi.exec(contents)[1].trim();
17
contents = contents.replace(/\bTPromise\b/g, 'Promise');
18
19
contents = `/*---------------------------------------------------------------------------------------------
20
* Copyright (c) Microsoft Corporation. All rights reserved.
21
* Licensed under the MIT License. See License.txt in the project root for license information.
22
*--------------------------------------------------------------------------------------------*/
23
24
${contents}
25
`;
26
27
const srcPath = path.join(path.dirname(__dirname), 'src');
28
const outPath = path.join(path.dirname(__dirname), 'out');
29
30
if (!fs.existsSync(outPath)) {
31
fs.mkdirSync(outPath);
32
}
33
fs.writeFileSync(path.join(srcPath, 'driver.d.ts'), contents);
34
fs.writeFileSync(path.join(outPath, 'driver.d.ts'), contents);
35
36