diff --git a/package.json b/package.json index 4ace0f8..de1cd81 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/scripts/build.js b/scripts/build.js index 1852b87..2e42663 100644 --- a/scripts/build.js +++ b/scripts/build.js @@ -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 = []) => { @@ -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', }); } };