chore: add script to adapt os memory (#48435)

* chore: add script to adapt os memory

* update

* update

* use typescript

* fix
This commit is contained in:
George H 2024-04-15 10:23:35 +08:00 committed by GitHub
parent 2a23f50c1a
commit bfa23e16a0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 15 additions and 1 deletions

View File

@ -87,7 +87,7 @@
"sort:api-table": "antd-tools run sort-api-table",
"sort:package-json": "npx sort-package-json",
"prestart": "npm run version && npm run token:statistic && npm run token:meta && npm run lint:changelog",
"start": "cross-env PORT=8001 dumi dev",
"start": "tsx ./scripts/set-node-options.ts cross-env PORT=8001 dumi dev",
"pretest": "npm run version",
"test": "jest --config .jest.js --no-cache",
"test:all": "sh -e ./scripts/test-all.sh",

View File

@ -0,0 +1,14 @@
import os from 'os';
const childProcess = require('child_process');
const totalMemory = Math.floor(os.totalmem() / (1024 * 1024));
if (totalMemory <= 8192) {
// setting NODE_OPTIONS
process.env.NODE_OPTIONS = '--max-old-space-size=4096';
// Execute project startup command
const args: string[] = process.argv.slice(2);
childProcess.execSync(` ${args.join(' ')}`, { stdio: 'inherit' });
}