mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
update: use build.js
This commit is contained in:
1 parent
15d2ecaf54
commit
50952050f8
5 files changed
+32
-15
No files matched your search
@@ -1,5 +1,7 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const child = require('child_process');
|
||||
const { argv } = require('yargs');
|
||||
|
||||
const compilerOptionsBase = {
|
||||
target: 'es2019',
|
||||
@@ -14,7 +16,10 @@ const compilerOptionsBase = {
|
||||
};
|
||||
const config = {
|
||||
compilerOptions: compilerOptionsBase,
|
||||
references: [{ path: 'tsconfig.build.json' }],
|
||||
references: [
|
||||
{ path: 'tsconfig.build.json' },
|
||||
{ path: 'packages/hydrooj' },
|
||||
],
|
||||
files: [],
|
||||
};
|
||||
const configSrc = {
|
||||
@@ -47,7 +52,7 @@ const configFlat = {
|
||||
const packages = fs.readdirSync(path.resolve(process.cwd(), 'packages'));
|
||||
console.log(packages);
|
||||
for (const package of packages) {
|
||||
config.references.push({ path: `packages/${package}` });
|
||||
if (package !== 'hydrooj') config.references.push({ path: `packages/${package}` });
|
||||
const files = fs.readdirSync(path.resolve(process.cwd(), 'packages', package));
|
||||
fs.writeFileSync(
|
||||
path.resolve(process.cwd(), 'packages', package, 'tsconfig.json'),
|
||||
@@ -55,3 +60,14 @@ for (const package of packages) {
|
||||
);
|
||||
}
|
||||
fs.writeFileSync(path.resolve(process.cwd(), 'tsconfig.json'), JSON.stringify(config));
|
||||
|
||||
if (argv.watch) {
|
||||
child.spawnSync('../node_modules/.bin/tsc -b --watch', { stdio: 'inherit' });
|
||||
} else {
|
||||
let result = child.spawnSync('../node_modules/.bin/tsc -b', { stdio: 'inherit' });
|
||||
if (result.status != 0) {
|
||||
result = child.spawnSync('../node_modules/.bin/tsc -b', { stdio: 'inherit' });
|
||||
}
|
||||
console.log(result);
|
||||
process.exit(result.status);
|
||||
}
|
||||
Reference in new issue
Block a user