@@ -4,6 +4,7 @@ const fs = require('fs');
4
4
const path = require ( 'path' ) ;
5
5
6
6
const HANDLEBARS_REGEX = / \. ( h b s | h a n d l e b a r s ) $ / ;
7
+ const JAVASCRIPT_REGEX = / \. ( j s ) $ / ;
7
8
8
9
const NODE_MODULE_DIRECTORIES = [
9
10
path . join ( __dirname , '../node_modules' ) ,
@@ -28,13 +29,7 @@ const findPackagePath = pkg =>
28
29
29
30
fs . stat ( path , ( err , stats ) => {
30
31
31
- if ( err ) {
32
-
33
- return resolve ( null ) ;
34
-
35
- }
36
-
37
- if ( stats . isDirectory ( ) ) {
32
+ if ( ! err && stats . isDirectory ( ) ) {
38
33
39
34
return resolve ( path ) ;
40
35
@@ -80,6 +75,7 @@ const loadParser = config => new Promise((resolve, reject) => {
80
75
*
81
76
* loadPlugin({'layout': 'markdown'}).then(plugin => {});
82
77
* loadPlugin({'layout': 'templates/README.hbs'}).then(plugin => {});
78
+ * loadPlugin({'layout': 'plugin.js'}).then(plugin => {});
83
79
*
84
80
* @param {Object } config Configuration object.
85
81
* @param {String } config.layout String representing the layout plugin to be loaded.
@@ -111,6 +107,10 @@ const loadPlugin = config => new Promise((resolve, reject) => {
111
107
112
108
resolve ( require ( 'doxdox-plugin-handlebars' ) ) ;
113
109
110
+ } else if ( stats && stats . isFile ( ) && config . layout . match ( JAVASCRIPT_REGEX ) ) {
111
+
112
+ resolve ( require ( `${ process . cwd ( ) } /${ config . layout } ` ) ) ;
113
+
114
114
} else {
115
115
116
116
reject ( 'Invalid layout specified.' ) ;
0 commit comments