Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/extensions/copilot/build/listBuildCacheFiles.js
13383 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
if (process.argv.length !== 3) {
13
console.error('Usage: node listBuildCacheFiles.js OUTPUT_FILE');
14
process.exit(-1);
15
}
16
17
const ROOT = path.join(__dirname, '../');
18
19
/**
20
* @param {string} location
21
* @param {string[]} result
22
*/
23
function listAllFiles(location, result) {
24
const entries = fs.readdirSync(path.join(ROOT, location));
25
for (const entry of entries) {
26
const entryPath = `${location}/${entry}`;
27
28
/** @type {import('fs').Stats} */
29
let stat;
30
try {
31
stat = fs.statSync(path.join(ROOT, entryPath));
32
} catch (err) {
33
continue;
34
}
35
36
if (stat.isDirectory()) {
37
listAllFiles(entryPath, result);
38
} else {
39
result.push(entryPath);
40
}
41
}
42
}
43
44
/** @type {string[]} */
45
const result = [];
46
listAllFiles('node_modules', result); // node modules
47
listAllFiles('dist', result); // contains wasm files
48
fs.writeFileSync(process.argv[2], result.join('\n') + '\n');
49
50