1
Fork 0

Replace the individual Yarn scripts with a single Node script.

This commit is contained in:
Bauke 2020-08-04 15:36:48 +02:00
parent d8027cf19b
commit fc31109291
Signed by: Bauke
GPG Key ID: C1C0F29952BCF558
4 changed files with 50 additions and 6 deletions

View File

@ -1,18 +1,14 @@
{ {
"name": "bauke.xyz", "name": "bauke.xyz",
"description": "My personal website.", "description": "My personal website.",
"version": "0.1.8", "version": "0.1.9",
"author": "Bauke <me@bauke.xyz>", "author": "Bauke <me@bauke.xyz>",
"homepage": "https://bauke.xyz", "homepage": "https://bauke.xyz",
"repository": "https://git.holllo.cc/Bauke/bauke.xyz", "repository": "https://git.holllo.cc/Bauke/bauke.xyz",
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {
"start": "nodemon --watch 'source/' --exec 'yarn build' --ext 'html css'", "start": "nodemon --watch 'source/' --exec 'yarn build' --ext 'html css'",
"build": "yarn build:cpy && yarn build:css && yarn build:userscripts && yarn build:userstyles", "build": "node 'source/index.js'",
"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'",
"test": "xo && stylelint 'source/css/*.css'", "test": "xo && stylelint 'source/css/*.css'",
"deploy": "rm -rf 'public/' && yarn build && yarn deploy:netlify", "deploy": "rm -rf 'public/' && yarn build && yarn deploy:netlify",
"deploy:netlify": "netlify deploy --prod --dir 'public/' -s 37bb1f7c-2abb-419f-9a31-a4b72209c1c8" "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" "userstyles": "git+https://git.holllo.cc/Bauke/userstyles.git"
}, },
"devDependencies": { "devDependencies": {
"cpy": "^8.1.0",
"cpy-cli": "^3.1.1", "cpy-cli": "^3.1.1",
"husky": "^4.2.5", "husky": "^4.2.5",
"netlify-cli": "^2.58.0", "netlify-cli": "^2.58.0",

39
source/index.js Normal file
View File

@ -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();
}

View File

@ -56,6 +56,10 @@ async function main() {
); );
} }
module.exports = {
build: main
};
// Run `main()` if this script was called directly (like `node source/userscripts.js`). // Run `main()` if this script was called directly (like `node source/userscripts.js`).
if (require.main === module) { if (require.main === module) {
main(); main();

View File

@ -49,6 +49,10 @@ async function main() {
); );
} }
module.exports = {
build: main
};
// Run `main()` if this script was called directly (like `node source/userstyles.js`). // Run `main()` if this script was called directly (like `node source/userstyles.js`).
if (require.main === module) { if (require.main === module) {
main(); main();