Skip to content

Commit ee9b796

Browse files
committed
Validate outputPath from compiler
The MemoryFs API throws an unclear error when using a relative path.
1 parent d5e0e9b commit ee9b796

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

middleware.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ module.exports = function(compiler, options) {
5555
if(typeof options.reporter !== "function") options.reporter = defaultReporter;
5656
if(typeof options.log !== "function") options.log = console.log.bind(console);
5757
if(typeof options.warn !== "function") options.warn = console.warn.bind(console);
58+
if(typeof compiler.outputPath === "string" && compiler.outputPath.lastIndexOf("/", 0) !== 0) {
59+
throw new Error('`output.path` needs to be an absolute path or "/".');
60+
}
5861

5962
// store our files in memory
6063
var fs;

test/FileSystem.test.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,12 @@ describe("FileSystem", function() {
2626

2727
should.strictEqual(firstFs, secondFs);
2828
});
29+
30+
it("should throw on invalid outputPath config", function() {
31+
var compiler = fakeWebpack();
32+
compiler.outputPath = "./dist";
33+
should.throws(function() {
34+
middleware(compiler);
35+
}, /output\.path/);
36+
});
2937
});

0 commit comments

Comments
 (0)