Skip to content

Commit e7c829f

Browse files
committed
[Issue #7] - Config should allow for post-command
1 parent 0c7e34d commit e7c829f

4 files changed

Lines changed: 20 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
### Additions
66

7+
- [Issue #7] - Config should allow for post-command
78
- [Issue #6] - Config creator should be able to append to existing config
89

910
### Fixes

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,12 @@ To remove the build and rebuild, run `html-baker -f`
2222

2323
## Configuration
2424

25+
- **precmd** - A command to run before the build starts
2526
- **domains** - An array of domain urls to download
2627
- **input** - If you have an app locally to download from, you can have it auto-start with these options
2728
- **directory** - Location of the app
2829
- **runcmd** - Command to run (start) the app. i.e. - `npm start`
2930
- **output**
3031
- **directory** - Directory to bake into
3132
- **options** - Array of wget options
33+
- **postcmd** - A command to run after the build succeeds

config.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"baker": {
3+
"precmd": "",
34
"domains": [
45
"localhost:3000"
56
],
@@ -17,6 +18,7 @@
1718
"--convert-links",
1819
"--restrict-file-names=windows",
1920
"--no-parent"
20-
]
21+
],
22+
"postcmd": ""
2123
}
2224
}

index.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ if (cli.force && config.output && config.output.directory) {
2727

2828
// Start the engine
2929

30+
// Run the precmd
31+
if (config.precmd && config.precmd.length) {
32+
console.log("Pre-cmd:", config.precmd);
33+
shell.execSync(config.precmd);
34+
}
35+
3036
/// Check for input server command
3137
let server = false;
3238
let serverStarted = false;
@@ -108,6 +114,13 @@ function download() {
108114

109115
try {
110116
shell.execSync(wgetcmd);
117+
118+
// Run the post command
119+
if (config.postcmd && config.postcmd.length) {
120+
console.log("Post-cmd:", config.postcmd);
121+
shell.execSync(config.postcmd);
122+
}
123+
111124
console.log("Done.");
112125
}
113126
catch (ex) {
@@ -125,4 +138,4 @@ function download() {
125138
}
126139
process.exit();
127140

128-
}
141+
}

0 commit comments

Comments
 (0)