script abstraction
This commit is contained in:
parent
b219494a4e
commit
6556968d32
11
lib/build.js
Normal file
11
lib/build.js
Normal 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
23
lib/clean.js
Normal 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.');
|
||||
});
|
||||
});
|
||||
});
|
|
@ -6,8 +6,8 @@
|
|||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"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",
|
||||
"build": "rm -rfv docs/* && hugo && sw-precache --root=docs && git add -A",
|
||||
"clean": "node lib/clean.js",
|
||||
"build": "node lib/build.js",
|
||||
"update": "node lib/update.js"
|
||||
},
|
||||
"pre-commit": [
|
||||
|
|
Loading…
Reference in New Issue
Block a user