mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 09:36:08 +08:00
workspace: auto export from src
This commit is contained in:
1 parent
6fb05fd5a0
commit
77a54b7663
2 files changed
+13
-3
No files matched your search
@@ -23,7 +23,6 @@ tsconfig.json
|
||||
packages/**/*.js
|
||||
!/build/build.js
|
||||
!**/bin/*.js
|
||||
!packages/hydrojudge/service.js
|
||||
|
||||
# Data files
|
||||
*.mmdb
|
||||
|
||||
+13
-2
@@ -48,13 +48,24 @@ const configFlat = {
|
||||
const packages = fs.readdirSync(path.resolve(process.cwd(), 'packages'));
|
||||
console.log(packages);
|
||||
for (const package of packages) {
|
||||
const files = fs.readdirSync(path.resolve(process.cwd(), 'packages', package));
|
||||
const basedir = path.resolve(process.cwd(), 'packages', package);
|
||||
const files = fs.readdirSync(basedir);
|
||||
if (!files.includes('src') && !files.map(n => n.split('.')[1]).includes('ts')) continue;
|
||||
if (package !== 'hydrooj') config.references.push({ path: `packages/${package}` });
|
||||
fs.writeFileSync(
|
||||
path.resolve(process.cwd(), 'packages', package, 'tsconfig.json'),
|
||||
path.resolve(basedir, 'tsconfig.json'),
|
||||
files.includes('src') ? JSON.stringify(configSrc) : JSON.stringify(configFlat),
|
||||
);
|
||||
if (files.includes('src')) {
|
||||
const inner = fs.readdirSync(path.resolve(basedir, 'src'));
|
||||
for (const file of inner) {
|
||||
if (!fs.statSync(path.resolve(basedir, 'src', file)).isFile()) continue;
|
||||
const name = file.split('.')[0];
|
||||
if (['handler', 'service', 'lib', 'model', 'script'].includes(name)) {
|
||||
fs.writeFileSync(path.resolve(basedir, name + '.js'), `module.exports = require('./dist/${name}');\n`)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
fs.writeFileSync(path.resolve(process.cwd(), 'tsconfig.json'), JSON.stringify(config));
|
||||
|
||||
|
||||
Reference in new issue
Block a user