Skip to content

Commit 49f7dcb

Browse files
committed
Fixed issue with absolute paths.
1 parent e9918f8 commit 49f7dcb

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

lib/loaders.js

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,15 @@ const loadParser = config => new Promise((resolve, reject) => {
7575

7676
} else if (stats && stats.isFile() && config.parser.match(JAVASCRIPT_PATTERN)) {
7777

78-
resolve(require(path.join(process.cwd(), config.parser)));
78+
if (path.isAbsolute(config.parser)) {
79+
80+
resolve(require(config.parser));
81+
82+
} else {
83+
84+
resolve(require(path.join(process.cwd(), config.parser)));
85+
86+
}
7987

8088
} else {
8189

@@ -126,7 +134,15 @@ const loadPlugin = config => new Promise((resolve, reject) => {
126134

127135
} else if (stats && stats.isFile() && config.layout.match(JAVASCRIPT_PATTERN)) {
128136

129-
resolve(require(path.join(process.cwd(), config.layout)));
137+
if (path.isAbsolute(config.layout)) {
138+
139+
resolve(require(config.layout));
140+
141+
} else {
142+
143+
resolve(require(path.join(process.cwd(), config.layout)));
144+
145+
}
130146

131147
} else {
132148

test/specs/loaders.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ describe('loaders', () => {
4545
loaders.loadParser({'parser': PARSER_PATH})
4646
.then(parser => assert.equal(typeof parser, 'function')));
4747

48-
it.skip('loads custom parser when file (absolute path) is specified', () =>
48+
it('loads custom parser when file (absolute path) is specified', () =>
4949
loaders.loadParser({'parser': PARSER_PATH_ABSOLUTE})
5050
.then(parser => assert.equal(typeof parser, 'function')));
5151

@@ -89,15 +89,15 @@ describe('loaders', () => {
8989
loaders.loadPlugin({'layout': TEMPLATE_PATH})
9090
.then(plugin => assert.equal(typeof plugin, 'function')));
9191

92-
it.skip('loads custom handlebars plugin when file (absolute path) is specified', () =>
92+
it('loads custom handlebars plugin when file (absolute path) is specified', () =>
9393
loaders.loadPlugin({'layout': TEMPLATE_PATH_ABSOLUTE})
9494
.then(plugin => assert.equal(typeof plugin, 'function')));
9595

9696
it('load custom plugin via JavaScript file', () =>
9797
loaders.loadPlugin({'layout': PLUGIN_PATH})
9898
.then(plugin => assert.equal(typeof plugin, 'function')));
9999

100-
it.skip('load custom plugin via JavaScript file (absolute path)', () =>
100+
it('load custom plugin via JavaScript file (absolute path)', () =>
101101
loaders.loadPlugin({'layout': PLUGIN_PATH_ABSOLUTE})
102102
.then(plugin => assert.equal(typeof plugin, 'function')));
103103

0 commit comments

Comments
 (0)