2020-04-14 21:22:34 +08:00
|
|
|
import * as glob from 'glob';
|
|
|
|
import * as path from 'path';
|
|
|
|
import * as fs from 'fs-extra';
|
|
|
|
import { run } from './fn/shell';
|
2020-02-13 23:14:08 +08:00
|
|
|
|
|
|
|
(async () => {
|
2020-04-14 21:22:34 +08:00
|
|
|
await run('npm run clean');
|
2020-02-13 23:14:08 +08:00
|
|
|
|
2021-09-23 14:03:34 +08:00
|
|
|
const fileParten = '*/src/**/!(*.ts|*.tsx|*.rs)';
|
2020-04-14 21:22:34 +08:00
|
|
|
console.log(`[COPY]: ${fileParten}`);
|
2020-02-13 23:14:08 +08:00
|
|
|
|
2020-04-14 21:22:34 +08:00
|
|
|
const cwd = path.join(__dirname, '../packages');
|
|
|
|
const files = glob.sync(fileParten, { cwd, nodir: true });
|
|
|
|
// eslint-disable-next-line
|
2020-02-13 23:14:08 +08:00
|
|
|
for (const file of files) {
|
2020-04-14 21:22:34 +08:00
|
|
|
const from = path.join(cwd, file);
|
|
|
|
const to = path.join(cwd, file.replace(/\/src\//, '/lib/'));
|
|
|
|
// eslint-disable-next-line
|
|
|
|
await fs.mkdirp(path.dirname(to));
|
|
|
|
// eslint-disable-next-line
|
|
|
|
await fs.copyFile(from, to);
|
2020-02-13 23:14:08 +08:00
|
|
|
}
|
2020-12-22 10:43:23 +08:00
|
|
|
await run('npx tsc --build ./tsconfig.json');
|
2020-02-13 23:14:08 +08:00
|
|
|
|
|
|
|
})().catch((e) => {
|
2020-04-14 21:22:34 +08:00
|
|
|
console.trace(e);
|
|
|
|
process.exit(128);
|
2020-02-13 23:14:08 +08:00
|
|
|
});
|