From 12f82f0f3dcea4d20d4e92b9f7f29069d1c385bb Mon Sep 17 00:00:00 2001 From: Alice Gaudon Date: Tue, 30 Mar 2021 12:44:09 +0200 Subject: [PATCH] package.json: use NodeJS scripts instead of unix commands --- .eslintrc.json | 1 + package.json | 10 +++++----- scripts/clean.js | 10 ++++++++++ scripts/prepare-sources.js | 4 ++++ 4 files changed, 20 insertions(+), 5 deletions(-) create mode 100644 scripts/clean.js create mode 100644 scripts/prepare-sources.js diff --git a/.eslintrc.json b/.eslintrc.json index cdf57c6..a506e1e 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -88,6 +88,7 @@ }, "ignorePatterns": [ "jest.config.js", + "scripts/**/*", "webpack.config.js", "dist/**/*", "public/**/*", diff --git a/package.json b/package.json index f7c65e8..2e8efd7 100644 --- a/package.json +++ b/package.json @@ -8,13 +8,13 @@ "main": "dist/main.js", "scripts": { "test": "jest --verbose --runInBand", - "clean": "(test ! -d dist || rm -r dist)", - "prepareSources": "cp package.json src/", + "clean": "node scripts/clean.js", + "prepare-sources": "node scripts/prepare-sources.js", "compile": "yarn clean && tsc", - "build": "yarn prepareSources && yarn compile && webpack --mode production", - "dev": "yarn prepareSources && concurrently -k -n \"Typescript,Node,Webpack,Maildev\" -p \"[{name}]\" -c \"blue,green,red,yellow\" \"tsc --watch\" \"nodemon\" \"webpack --watch --mode development\" \"maildev\"", + "build": "yarn prepare-sources && yarn compile && webpack --mode production", + "dev": "yarn prepare-sources && concurrently -k -n \"Typescript,Node,Webpack,Maildev\" -p \"[{name}]\" -c \"blue,green,red,yellow\" \"tsc --watch\" \"nodemon\" \"webpack --watch --mode development\" \"maildev\"", "start": "yarn build && node", - "lint": "eslint . --ext .js,.jsx,.ts,.tsx" + "lint": "eslint ." }, "devDependencies": { "@babel/core": "^7.9.0", diff --git a/scripts/clean.js b/scripts/clean.js new file mode 100644 index 0000000..d5ef093 --- /dev/null +++ b/scripts/clean.js @@ -0,0 +1,10 @@ +const fs = require('fs'); + +[ + 'dist', +].forEach(file => { + if (fs.existsSync(file)) { + console.log('Cleaning', file, '...'); + fs.rmSync(file, {recursive: true}); + } +}); diff --git a/scripts/prepare-sources.js b/scripts/prepare-sources.js new file mode 100644 index 0000000..a78c2f3 --- /dev/null +++ b/scripts/prepare-sources.js @@ -0,0 +1,4 @@ +const fs = require('fs'); +const path = require('path'); + +fs.copyFileSync('package.json', path.join('src', 'package.json'));