Skip to content

Commit 7df05c7

Browse files
committed
fixed missing mkdirp for records, webpack#90
1 parent 4c3d903 commit 7df05c7

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

lib/Compiler.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,20 @@ Compiler.prototype.emitAssets = function(compilation, callback) {
233233

234234
Compiler.prototype.emitRecords = function emitRecords(callback) {
235235
if(!this.recordsOutputPath) return callback();
236-
this.outputFileSystem.writeFile(this.recordsOutputPath, JSON.stringify(this.records, undefined, 2), callback);
236+
var idx1 = this.recordsOutputPath.lastIndexOf("/");
237+
var idx2 = this.recordsOutputPath.lastIndexOf("\\");
238+
var recordsOutputPathDirectory = null;
239+
if(idx1 > idx2) recordsOutputPathDirectory = this.recordsOutputPath.substr(0, idx1);
240+
if(idx1 < idx2) recordsOutputPathDirectory = this.recordsOutputPath.substr(0, idx2);
241+
if(!recordsOutputPathDirectory) return writeFile.call(this);
242+
this.outputFileSystem.mkdirp(recordsOutputPathDirectory, function(err) {
243+
if(err) return callback(err);
244+
writeFile.call(this)
245+
}.bind(this));
246+
247+
function writeFile() {
248+
this.outputFileSystem.writeFile(this.recordsOutputPath, JSON.stringify(this.records, undefined, 2), callback);
249+
}
237250
};
238251

239252
Compiler.prototype.readRecords = function readRecords(callback) {
@@ -245,7 +258,7 @@ Compiler.prototype.readRecords = function readRecords(callback) {
245258
// It doesn't exist
246259
// We can ignore this.
247260
if(err) return callback();
248-
261+
249262
this.inputFileSystem.readFile(this.recordsInputPath, function(err, content) {
250263
if(err) return callback(err);
251264

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "webpack",
3-
"version": "0.10.0-beta18",
3+
"version": "0.10.0-beta19",
44
"author": "Tobias Koppers @sokra",
55
"description": "Packs CommonJs/AMD/Labeled Modules for the browser. Allows to split your codebase into multiple bundles, which can be loaded on demand. Support loaders to preprocess files, i.e. json, jade, coffee, css, less, ... and your custom stuff.",
66
"dependencies": {

test/browsertest/middlewareTest.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,10 @@ app.configure(function() {
2828
optimize: {
2929
minimize: true
3030
},
31+
recordsPath: path.join(__dirname, "webpack.records.json"),
3132
output: {
3233
publicPath: "http://localhost:8080/js/",
34+
path: "/",
3335
filename: "web.js"
3436
}
3537
}), {

0 commit comments

Comments
 (0)