Skip to content

Commit f177bf5

Browse files
committed
Fix callback error in fs.writeFile, cleanup require statements
1 parent 0abcfda commit f177bf5

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

bin/htmlbook

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
#!/usr/bin/env node
22

3-
var sys = require('sys'),
4-
fs = require('fs'),
5-
optparse = require('optparse'),
6-
path = require('path'),
7-
htmlbook = require('../htmlbook'),
8-
html = require('html'),
9-
cwd = process.cwd();
3+
const fs = require('fs');
4+
const optparse = require('optparse');
5+
const path = require('path');
6+
const htmlbook = require('../htmlbook');
7+
const html = require('html');
8+
const cwd = process.cwd();
109

1110
// Define an option called ´´help´´. We give it a quick alias named ´´-h´´
1211
// and a quick help text.
@@ -50,24 +49,26 @@ parser.on('output', function (name, value) {
5049
})
5150

5251
parser.on('help', function() {
53-
sys.puts(parser.toString());
52+
console.log(parser.toString());
5453
});
5554

5655
parser.parse(process.argv);
5756

5857
if (source_path) {
5958
fs.readFile(source_path, 'utf8', function (err, data) {
6059
if (err) {
61-
sys.puts(err);
60+
console.log(err);
6261
process.exit(1);
6362
}
6463

6564
var result = htmlbook(data).parse(options);
6665

6766
if (output_path) {
68-
fs.writeFile(output_path, result);
67+
fs.writeFile(output_path, result, (err) => {
68+
if (err) throw err;
69+
})
6970
} else {
70-
sys.puts(result);
71+
console.log(result);
7172
}
7273
});
7374
} else {
@@ -78,7 +79,7 @@ if (source_path) {
7879
if (output_path) {
7980
fs.writeFile(output_path, result);
8081
} else {
81-
sys.puts(result);
82+
console.log(result);
8283
}
8384
}
84-
}
85+
}

0 commit comments

Comments
 (0)