From 0f04e431322a83b95e49532cce7d6a8e49864c1f Mon Sep 17 00:00:00 2001 From: cha0s Date: Sat, 20 Mar 2021 10:46:27 -0500 Subject: [PATCH] fix: args and cleaning --- packages/build/package.json | 3 +-- packages/build/src/build.js | 20 +++++++++++++++----- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/packages/build/package.json b/packages/build/package.json index ea9a48f..687fc8a 100644 --- a/packages/build/package.json +++ b/packages/build/package.json @@ -8,8 +8,7 @@ "latus-build": "./build.js" }, "scripts": { - "build": "LATUS_POSTCSS_CONFIG=./src/build/postcss.config.js NODE_PATH=./node_modules webpack --config ./webpack.config.js --mode production", - "clean": "rm -rf yarn.lock node_modules/* $(node -e \"process.stdout.write(require('./package.json').files.filter((file) => {const parts = file.split('/'); return 1 === parts.length || 'test' !== parts[0];}).join(' '));\")", + "build": "LATUS_POSTCSS_CONFIG=./src/build/postcss.config.js LATUS_WEBPACK_CONFIG=./src/build/webpack.config.js NODE_PATH=./node_modules webpack --config ./webpack.config.js --mode production", "fp": "npm unpublish --force $(node -e 'const {name, version} = require(`./package.json`); process.stdout.write(`${name}@${version}`)') && npm publish", "lint": "NODE_PATH=./node_modules eslint --config ./.eslintrc.js --format codeframe --ext mjs,js .", "test": "yarn --silent run build --display none && mocha --colors test.js" diff --git a/packages/build/src/build.js b/packages/build/src/build.js index 7e6a069..57f1775 100755 --- a/packages/build/src/build.js +++ b/packages/build/src/build.js @@ -70,16 +70,25 @@ const clean = () => { rimraf.sync(join(cwd, 'node_modules', '*')); rimraf.sync(join(cwd, 'yarn.lock')); const {files} = __non_webpack_require__(join(cwd, 'package.json')); - rimraf.sync( - files - .map((filename) => join(cwd, filename)) - .join(' '), + if (files && files.length > 0) { + rimraf.sync( + files + .map((filename) => join(cwd, filename)) + .join(' '), + ); + } + spawn( + 'yarn', + [], + { + stdio: 'inherit', + }, ); }; program .command('clean') - .description('remove node_modules, yarn.lock, and build artifacts') + .description('remove node_modules, yarn.lock, and build artifacts and run yarn') .action(clean); const unpublish = async () => { @@ -162,6 +171,7 @@ program .action(lint); const test = async () => { + process.argv.splice(2, 1); await build(['--display', 'none']); const {production} = program.opts(); const configFile = localConfig('.eslintrc.js');