-
Notifications
You must be signed in to change notification settings - Fork 40.1k
Expand file tree
/
Copy pathvscodeDtsCheck.js
More file actions
62 lines (49 loc) · 2.04 KB
/
vscodeDtsCheck.js
File metadata and controls
62 lines (49 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
// Usage: node script/build/vscodeDtsCheck.js
// Compares proposed d.ts files in src/extension/ against the repo's
// src/vscode-dts/ directory. Exits with code 1 if files are out of date.
const fs = require('fs');
const path = require('path');
const vscodeDtsDir = path.resolve('..', '..', 'src', 'vscode-dts');
const targetDir = path.resolve('src', 'extension');
function main() {
const pkg = JSON.parse(fs.readFileSync('package.json', 'utf-8'));
const proposals = pkg.enabledApiProposals;
if (!proposals || proposals.length === 0) {
console.error('No enabledApiProposals found in package.json.');
process.exit(1);
}
console.log('Checking proposed d.ts files against src/vscode-dts/...');
const mismatched = [];
for (const proposal of proposals) {
const fileName = `vscode.proposed.${proposal}.d.ts`;
const sourcePath = path.join(vscodeDtsDir, fileName);
const committedPath = path.join(targetDir, fileName);
if (!fs.existsSync(sourcePath)) {
console.warn(`Warning: ${fileName} not found in src/vscode-dts/, skipping`);
continue;
}
const sourceContent = fs.readFileSync(sourcePath, 'utf-8');
if (!fs.existsSync(committedPath)) {
mismatched.push(fileName + ' (missing)');
} else {
const committedContent = fs.readFileSync(committedPath, 'utf-8');
if (sourceContent !== committedContent) {
mismatched.push(fileName);
}
}
}
if (mismatched.length > 0) {
console.error('The following proposed API type definitions are out of date:');
for (const f of mismatched) {
console.error(` - ${f}`);
}
console.error('Run "npm run vscode-dts:update" and commit the changes.');
process.exit(1);
}
console.log('All proposed API type definitions are up to date.');
}
main();