ice/scripts/build.ts

29 lines
796 B
TypeScript
Raw Normal View History

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 () => {
await run('npm run clean');
2020-02-13 23:14:08 +08:00
const fileParten = '*/src/**/!(*.ts|*.tsx|*.rs)';
console.log(`[COPY]: ${fileParten}`);
2020-02-13 23:14:08 +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) {
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
}
await run('npx tsc --build ./tsconfig.json');
2020-02-13 23:14:08 +08:00
})().catch((e) => {
console.trace(e);
process.exit(128);
2020-02-13 23:14:08 +08:00
});