Merge pull request #5 from ThePacielloGroup/clean-script

script abstraction
This commit is contained in:
Heydon Pickering 2017-09-13 10:16:45 +01:00 committed by GitHub
commit 28aad4750d
3 changed files with 36 additions and 2 deletions

11
lib/build.js Normal file
View File

@ -0,0 +1,11 @@
var exec = require('child_process').exec;
var path = require('path');
exec('rm -rfv ' + path.join(path.resolve('.'), 'docs', '*') + ' && hugo && sw-precache --root=docs && git add -A', function(error, stdout, stderr) {
console.log('Building...');
if (error !== null) {
console.error('Error building site.');
return;
}
console.log('Site built at /docs.');
});

23
lib/clean.js Normal file
View File

@ -0,0 +1,23 @@
var exec = require('child_process').exec;
var path = require('path');
exec('rm -rf ' + path.join(path.resolve('.'), 'content') + ' && mkdir content && mkdir ' + path.join('content', 'patterns'), function(error, stdout, stderr) {
console.log('Initializing new project...');
if (error !== null) {
console.error('Error creating folder structure.');
return;
}
exec ('hugo new ' + path.join('patterns', 'pattern.md') + ' && hugo new _index.md && hugo new print-version.md --kind print-version', function(error, stdout, stderr) {
if (error !== null) {
console.error('Error creating new project files.');
return;
}
exec ('cat ' + path.join('themes', 'infusion', 'data', 'README_BLANK.md') + ' > README.md', function(error, stdout, stderr) {
if (error !== null) {
console.error('Error initializing README file.');
return;
}
console.log('New project ready. See patterns/pattern.md to get started.');
});
});
});

View File

@ -6,8 +6,8 @@
"scripts": { "scripts": {
"test": "echo \"Error: no test specified\" && exit 1", "test": "echo \"Error: no test specified\" && exit 1",
"serve": "hugo server --baseURL http://localhost:1313", "serve": "hugo server --baseURL http://localhost:1313",
"clean": "rm -rf content && mkdir content && mkdir content/patterns && hugo new patterns/pattern.md && hugo new _index.md && hugo new print-version.md --kind print-version && cat themes/infusion/data/README_BLANK.md > README.md", "clean": "node lib/clean.js",
"build": "rm -rfv docs/* && hugo && sw-precache --root=docs && git add -A", "build": "node lib/build.js",
"update": "node lib/update.js" "update": "node lib/update.js"
}, },
"pre-commit": [ "pre-commit": [