Skip to content

Commit edfc428

Browse files
committed
Simplified method.
1 parent 176c2ab commit edfc428

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

lib/doxdox.js

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ const DEFAULT_IGNORE_PATHS = [
1212
'!**/Gulpfile.js'
1313
];
1414

15+
const REPLACE_FILENAME_REGEXP = new RegExp(`${process.cwd()}/|./`);
16+
1517
/**
1618
* Parse an input file with parser.
1719
*
@@ -25,23 +27,15 @@ const DEFAULT_IGNORE_PATHS = [
2527
*/
2628

2729
const parseInput = (input, config) =>
28-
loaders.loadParser(config).then(parser => new Promise((resolve, reject) => {
29-
30-
fs.readFile(input, 'utf8', (err, data) => {
31-
32-
if (err) {
33-
34-
return reject(err);
35-
36-
}
30+
loaders.loadParser(config).then(parser => new Promise(resolve => {
3731

38-
const filename = input.replace(`${process.cwd()}/`, '');
32+
const data = fs.readFileSync(input, 'utf8');
3933

40-
return resolve({
41-
'methods': parser(data, filename),
42-
'name': filename
43-
});
34+
const filename = input.replace(REPLACE_FILENAME_REGEXP, '');
4435

36+
return resolve({
37+
'methods': parser(data, filename),
38+
'name': filename
4539
});
4640

4741
}));

0 commit comments

Comments
 (0)