g6/packages/site/scripts/env-setup.cjs
Yuxin ced681f309
feat: api reference builder (#5347)
* feat: api reference builder

* chore: generate api docs before build site

---------

Co-authored-by: yvonneyx <banxuan.zyx@antgroup.com>
2024-01-17 09:28:57 +08:00

21 lines
543 B
JavaScript

// eslint-disable-next-line @typescript-eslint/no-var-requires
const fs = require('fs');
const setEnv = (env, value) => {
process.env[env] = value;
};
const updatePackageJson = () => {
const packageJson = JSON.parse(fs.readFileSync('package.json', 'utf8'));
if (process.env.USE_TS_NODE === 'true') {
packageJson.type = 'module';
} else {
delete packageJson.type;
}
fs.writeFileSync('package.json', JSON.stringify(packageJson, null, 2));
};
const [, , env, value] = process.argv;
setEnv(env, value);
updatePackageJson();