void/build/azure-pipelines/common/listNodeModules.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

44 lines
1.8 KiB
JavaScript
Raw Permalink Normal View History

2024-09-11 02:37:36 +00:00
"use strict";
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
2025-03-01 02:01:53 +00:00
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
2024-09-11 02:37:36 +00:00
Object.defineProperty(exports, "__esModule", { value: true });
2025-03-01 02:01:53 +00:00
const fs_1 = __importDefault(require("fs"));
const path_1 = __importDefault(require("path"));
2024-09-11 02:37:36 +00:00
if (process.argv.length !== 3) {
console.error('Usage: node listNodeModules.js OUTPUT_FILE');
process.exit(-1);
}
2025-03-01 02:01:53 +00:00
const ROOT = path_1.default.join(__dirname, '../../../');
2024-09-11 02:37:36 +00:00
function findNodeModulesFiles(location, inNodeModules, result) {
2025-03-01 02:01:53 +00:00
const entries = fs_1.default.readdirSync(path_1.default.join(ROOT, location));
2024-09-11 02:37:36 +00:00
for (const entry of entries) {
const entryPath = `${location}/${entry}`;
if (/(^\/out)|(^\/src$)|(^\/.git$)|(^\/.build$)/.test(entryPath)) {
continue;
}
let stat;
try {
2025-03-01 02:01:53 +00:00
stat = fs_1.default.statSync(path_1.default.join(ROOT, entryPath));
2024-09-11 02:37:36 +00:00
}
catch (err) {
continue;
}
if (stat.isDirectory()) {
findNodeModulesFiles(entryPath, inNodeModules || (entry === 'node_modules'), result);
}
else {
if (inNodeModules) {
result.push(entryPath.substr(1));
}
}
}
}
const result = [];
findNodeModulesFiles('', false, result);
2025-03-01 02:01:53 +00:00
fs_1.default.writeFileSync(process.argv[2], result.join('\n') + '\n');
2024-09-11 02:37:36 +00:00
//# sourceMappingURL=listNodeModules.js.map