55 lines
1.2 KiB
JavaScript
55 lines
1.2 KiB
JavaScript
import {
|
|
existsSync,
|
|
readdirSync,
|
|
realpathSync,
|
|
statSync,
|
|
} from 'node:fs';
|
|
import { join } from 'node:path';
|
|
import { spawnSync } from 'node:child_process';
|
|
|
|
const modulesPath = join(process.cwd(), 'Modules');
|
|
|
|
if (!existsSync(modulesPath)) {
|
|
process.exit(0);
|
|
}
|
|
|
|
const installed = new Set();
|
|
|
|
for (const moduleName of readdirSync(modulesPath)) {
|
|
const modulePath = join(modulesPath, moduleName);
|
|
|
|
if (!statSync(modulePath).isDirectory()) {
|
|
continue;
|
|
}
|
|
|
|
const packageJson = join(modulePath, 'package.json');
|
|
const packageLock = join(modulePath, 'package-lock.json');
|
|
|
|
if (!existsSync(packageJson) || !existsSync(packageLock)) {
|
|
continue;
|
|
}
|
|
|
|
const physicalModulePath = realpathSync(modulePath);
|
|
|
|
if (installed.has(physicalModulePath)) {
|
|
continue;
|
|
}
|
|
|
|
installed.add(physicalModulePath);
|
|
|
|
console.log(`[Modules] Installing npm dependencies for ${moduleName}...`);
|
|
|
|
const result = spawnSync(
|
|
'npm',
|
|
['ci', '--no-audit', '--no-fund'],
|
|
{
|
|
cwd: modulePath,
|
|
stdio: 'inherit',
|
|
},
|
|
);
|
|
|
|
if (result.status !== 0) {
|
|
process.exit(result.status ?? 1);
|
|
}
|
|
}
|