Skip to content

Commit

Permalink
chore: 🤖 optimize build.js
Browse files Browse the repository at this point in the history
  • Loading branch information
lenconda committed Sep 2, 2021
1 parent 0da2d7a commit 52705b4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
7 changes: 1 addition & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
{
"private": true,
"scripts": {
"watch:utils": "cd packages/dollie-utils && npm run build:watch",
"watch:cli": "cd packages/dollie-cli && npm run build:watch",
"watch:core": "cd packages/dollie-core && npm run build:watch",
"watch:origins": "cd packages/dollie-origins && npm run build:watch",
"init-watch": "npm run build",
"watch": "concurrently \"npm:watch:*\"",
"watch": "node scripts/build.js --watch",
"build": "node scripts/build.js",
"docs:start": "dumi dev",
"docs:build": "dumi build",
Expand Down
16 changes: 13 additions & 3 deletions scripts/build.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
const getPaths = require('../utils/paths');
const path = require('path');
const { program } = require('commander');
const { execSync } = require('child_process');
const {
spawn,
spawnSync,
} = require('child_process');
const fs = require('fs-extra');

const build = (watch = false, selectedPackages = []) => {
Expand Down Expand Up @@ -55,9 +58,16 @@ const build = (watch = false, selectedPackages = []) => {
}

console.log(`[BUILD]${watch ? '[WATCH]' : ''}`, name);
fs.removeSync(path.resolve(pathname, './lib'));
execSync(`tsc${watch ? '--watch' : ''}`, {

if (!watch) {
fs.removeSync(path.resolve(pathname, './lib'));
}

const execute = watch ? spawn : spawnSync;

execute('tsc', (watch ? ['--watch'] : []), {
cwd: pathname,
stdio: 'inherit',
});
}
};
Expand Down

0 comments on commit 52705b4

Please sign in to comment.