Skip to content

Commit bb639e2

Browse files
committed
[Issue #8] - Wget creates .1.html files
1 parent e7c829f commit bb639e2

4 files changed

Lines changed: 26 additions & 1 deletion

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 #8] - Wget creates .1.html files
78
- [Issue #7] - Config should allow for post-command
89
- [Issue #6] - Config creator should be able to append to existing config
910

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,6 @@ To remove the build and rebuild, run `html-baker -f`
2929
- **runcmd** - Command to run (start) the app. i.e. - `npm start`
3030
- **output**
3131
- **directory** - Directory to bake into
32+
- **fixDotOnes** - (boolean) If html-baker should convert wget's .1 files to .html files
3233
- **options** - Array of wget options
3334
- **postcmd** - A command to run after the build succeeds

config.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
"runcmd": "npm start"
1010
},
1111
"output": {
12-
"directory": "./docs"
12+
"directory": "./docs",
13+
"fixDotOnes": true
1314
},
1415
"options": [
1516
"--recursive",

index.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const shell = require("child_process");
2+
const fs = require("fs");
23

34
// Load cli
45
let cli = require("./lib/cli")();
@@ -121,6 +122,27 @@ function download() {
121122
shell.execSync(config.postcmd);
122123
}
123124

125+
// Fix dot ones
126+
if (config.output && config.output.fixDotOnes) {
127+
128+
// Scan the directory
129+
fs.readdirSync(config.output.directory).forEach(file => {
130+
if (file.includes(".1.html")) {
131+
132+
file = config.output.directory + '/' + file;
133+
let newfile = file.replace(".1.html", ".html");
134+
135+
try {
136+
fs.renameSync(file, newfile);
137+
}
138+
catch (ex) {
139+
throw "Could not move file " + file;
140+
}
141+
}
142+
});
143+
144+
}
145+
124146
console.log("Done.");
125147
}
126148
catch (ex) {

0 commit comments

Comments
 (0)