feat(GOV-009): 建立 NestJS 三进程基线
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
import { access, readdir } from 'node:fs/promises';
|
||||
|
||||
const expectedOutputs = [
|
||||
'dist/apps/api/main.js',
|
||||
'dist/apps/scheduler/main.js',
|
||||
'dist/apps/worker/main.js',
|
||||
];
|
||||
|
||||
await Promise.all(expectedOutputs.map((output) => access(output)));
|
||||
|
||||
const sourceDirectories = ['apps', 'libs', 'test'];
|
||||
const leakedOutputs = [];
|
||||
|
||||
async function findLeakedOutputs(directory) {
|
||||
for (const entry of await readdir(directory, { withFileTypes: true })) {
|
||||
const target = `${directory}/${entry.name}`;
|
||||
if (entry.isDirectory()) await findLeakedOutputs(target);
|
||||
if (entry.isFile() && /\.(?:js|js\.map|d\.ts)$/.test(entry.name)) leakedOutputs.push(target);
|
||||
}
|
||||
}
|
||||
|
||||
await Promise.all(sourceDirectories.map(findLeakedOutputs));
|
||||
if (leakedOutputs.length > 0) {
|
||||
throw new Error(`构建产物不得写入源码目录:${leakedOutputs.join('、')}`);
|
||||
}
|
||||
Reference in New Issue
Block a user