hangar51-loader
Advanced tools
Comparing version 0.0.8 to 0.0.9
@@ -312,11 +312,14 @@ module.exports = | ||
Manifest.prototype.save = function(callback) { | ||
var data, error; | ||
var data; | ||
data = JSON.stringify(this._fileMap, null, 2); | ||
try { | ||
fs.writeFileSync(this._manifestPath, data); | ||
callback(null, this); | ||
} catch (error1) { | ||
error = new Error("Unable to write " + this._manifestPath); | ||
callback(error, null); | ||
} | ||
return fs.writeFile(this._manifestPath, data, (function(_this) { | ||
return function(error) { | ||
if (error) { | ||
error = new Error("Unable to write " + _this._manifestPath); | ||
callback(error, null); | ||
return; | ||
} | ||
callback(null, _this); | ||
}; | ||
})(this)); | ||
}; | ||
@@ -334,27 +337,30 @@ | ||
Manifest.load = function(manifestPath, callback) { | ||
var data, error, fileMap; | ||
var error, fileMap, k, v; | ||
manifestPath = manifestPath || this._DEFAULT_PATH; | ||
if (Manifest._MANIFESTS[manifestPath]) { | ||
callback(null, this._MANIFESTS[manifestPath]); | ||
callback(null, Manifest._MANIFESTS[manifestPath]); | ||
return; | ||
} | ||
Manifest._MANIFESTS[manifestPath] = new Manifest(manifestPath); | ||
if (!fs.existsSync(manifestPath)) { | ||
Manifest._MANIFESTS[manifestPath] = new Manifest(manifestPath); | ||
callback(null, Manifest._MANIFESTS[manifestPath]); | ||
return; | ||
} | ||
try { | ||
data = fs.readFileSync(manifestPath); | ||
try { | ||
fileMap = JSON.parse(data); | ||
} catch (error1) { | ||
callback(new Error(manifestPath + " is corrupt"), null); | ||
return; | ||
} | ||
Manifest._MANIFESTS[manifestPath] = new Manifest(manifestPath, fileMap); | ||
callback(null, Manifest._MANIFESTS[manifestPath]); | ||
} catch (error1) { | ||
fs.readFile(manifestPath, function(error, data) {}); | ||
if (error) { | ||
error = new Error("Unable to read " + manifestPath); | ||
callback(error, null); | ||
return; | ||
} | ||
try { | ||
fileMap = JSON.parse(data); | ||
} catch (error1) { | ||
callback(new Error(manifestPath + " is corrupt"), null); | ||
return; | ||
} | ||
for (k in fileMap) { | ||
v = fileMap[k]; | ||
Manifest._MANIFESTS[manifestPath].fileMap[k] = v; | ||
} | ||
callback(null, Manifest._MANIFESTS[manifestPath]); | ||
}; | ||
@@ -361,0 +367,0 @@ |
{ | ||
"name": "hangar51-loader", | ||
"version": "0.0.8", | ||
"version": "0.0.9", | ||
"description": "Hangar51 webpack loader.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
34560
407