From fc31109291acee17ae7f7c2e0e3b5e65be433f23 Mon Sep 17 00:00:00 2001 From: Bauke Date: Tue, 4 Aug 2020 15:36:48 +0200 Subject: [PATCH] Replace the individual Yarn scripts with a single Node script. --- package.json | 9 +++------ source/index.js | 39 +++++++++++++++++++++++++++++++++++++++ source/userscripts.js | 4 ++++ source/userstyles.js | 4 ++++ 4 files changed, 50 insertions(+), 6 deletions(-) create mode 100644 source/index.js diff --git a/package.json b/package.json index e33cff5..4a3976d 100644 --- a/package.json +++ b/package.json @@ -1,18 +1,14 @@ { "name": "bauke.xyz", "description": "My personal website.", - "version": "0.1.8", + "version": "0.1.9", "author": "Bauke ", "homepage": "https://bauke.xyz", "repository": "https://git.holllo.cc/Bauke/bauke.xyz", "license": "MIT", "scripts": { "start": "nodemon --watch 'source/' --exec 'yarn build' --ext 'html css'", - "build": "yarn build:cpy && yarn build:css && yarn build:userscripts && yarn build:userstyles", - "build:cpy": "cpy '**' '!index.js' '!userstyles/*' '!userscripts/*' '../public/' --cwd='source' --parents", - "build:css": "cpy 'node_modules/modern-normalize/modern-normalize.css' 'public/css/'", - "build:userscripts": "node 'source/userscripts.js'", - "build:userstyles": "node 'source/userstyles.js'", + "build": "node 'source/index.js'", "test": "xo && stylelint 'source/css/*.css'", "deploy": "rm -rf 'public/' && yarn build && yarn deploy:netlify", "deploy:netlify": "netlify deploy --prod --dir 'public/' -s 37bb1f7c-2abb-419f-9a31-a4b72209c1c8" @@ -23,6 +19,7 @@ "userstyles": "git+https://git.holllo.cc/Bauke/userstyles.git" }, "devDependencies": { + "cpy": "^8.1.0", "cpy-cli": "^3.1.1", "husky": "^4.2.5", "netlify-cli": "^2.58.0", diff --git a/source/index.js b/source/index.js new file mode 100644 index 0000000..9226354 --- /dev/null +++ b/source/index.js @@ -0,0 +1,39 @@ +const cpy = require('cpy'); + +const {build: buildUserscripts} = require('./userscripts'); +const {build: buildUserstyles} = require('./userstyles'); + +async function main() { + console.log('Copying files.'); + await cpy( + [ + '**', + '!index.js', + '!userscripts.js', + '!userstyles.js', + '!userscripts/*', + '!userstyles/*' + ], + '../public/', + { + cwd: 'source', + parents: true + } + ); + + await cpy( + ['node_modules/modern-normalize/modern-normalize.css'], + 'public/css/' + ); + + console.log('Building userscripts.'); + await buildUserscripts(); + + console.log('Building userstyles.'); + await buildUserstyles(); +} + +// Run `main()` if this script was called directly (like `node source/index.js`). +if (require.main === module) { + main(); +} diff --git a/source/userscripts.js b/source/userscripts.js index f6174f8..acd7fb9 100644 --- a/source/userscripts.js +++ b/source/userscripts.js @@ -56,6 +56,10 @@ async function main() { ); } +module.exports = { + build: main +}; + // Run `main()` if this script was called directly (like `node source/userscripts.js`). if (require.main === module) { main(); diff --git a/source/userstyles.js b/source/userstyles.js index ddd0d4c..3184bce 100644 --- a/source/userstyles.js +++ b/source/userstyles.js @@ -49,6 +49,10 @@ async function main() { ); } +module.exports = { + build: main +}; + // Run `main()` if this script was called directly (like `node source/userstyles.js`). if (require.main === module) { main();