From 7df05c7ddcf3df90838a6d89edbf4ac95a99ee5a Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Mon, 10 Jun 2013 14:25:54 +0200 Subject: [PATCH] fixed missing mkdirp for records, #90 --- lib/Compiler.js | 17 +++++++++++++++-- package.json | 2 +- test/browsertest/middlewareTest.js | 2 ++ 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/lib/Compiler.js b/lib/Compiler.js index 58af74d71..5bdb3191a 100644 --- a/lib/Compiler.js +++ b/lib/Compiler.js @@ -233,7 +233,20 @@ Compiler.prototype.emitAssets = function(compilation, callback) { Compiler.prototype.emitRecords = function emitRecords(callback) { if(!this.recordsOutputPath) return callback(); - this.outputFileSystem.writeFile(this.recordsOutputPath, JSON.stringify(this.records, undefined, 2), callback); + var idx1 = this.recordsOutputPath.lastIndexOf("/"); + var idx2 = this.recordsOutputPath.lastIndexOf("\\"); + var recordsOutputPathDirectory = null; + if(idx1 > idx2) recordsOutputPathDirectory = this.recordsOutputPath.substr(0, idx1); + if(idx1 < idx2) recordsOutputPathDirectory = this.recordsOutputPath.substr(0, idx2); + if(!recordsOutputPathDirectory) return writeFile.call(this); + this.outputFileSystem.mkdirp(recordsOutputPathDirectory, function(err) { + if(err) return callback(err); + writeFile.call(this) + }.bind(this)); + + function writeFile() { + this.outputFileSystem.writeFile(this.recordsOutputPath, JSON.stringify(this.records, undefined, 2), callback); + } }; Compiler.prototype.readRecords = function readRecords(callback) { @@ -245,7 +258,7 @@ Compiler.prototype.readRecords = function readRecords(callback) { // It doesn't exist // We can ignore this. if(err) return callback(); - + this.inputFileSystem.readFile(this.recordsInputPath, function(err, content) { if(err) return callback(err); diff --git a/package.json b/package.json index 940301cbf..a21efbc4b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "webpack", - "version": "0.10.0-beta18", + "version": "0.10.0-beta19", "author": "Tobias Koppers @sokra", "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.", "dependencies": { diff --git a/test/browsertest/middlewareTest.js b/test/browsertest/middlewareTest.js index 09a344775..f15bf8bea 100644 --- a/test/browsertest/middlewareTest.js +++ b/test/browsertest/middlewareTest.js @@ -28,8 +28,10 @@ app.configure(function() { optimize: { minimize: true }, + recordsPath: path.join(__dirname, "webpack.records.json"), output: { publicPath: "http://localhost:8080/js/", + path: "/", filename: "web.js" } }), {