Comparing version 4.5.0 to 5.0.0
@@ -8,2 +8,3 @@ 'use strict'; | ||
var Path = require('path'); | ||
var when = require('when'); | ||
var node = require('when/node'); | ||
@@ -160,7 +161,9 @@ var fs = node.liftAll(require('fs')); | ||
var file = fs.readFile(pathName, 'utf8'); | ||
var sourceFile = fs.readFile(pathName, 'utf8'); | ||
var sourceFileContents = null; | ||
var continuation = file.then(function(result) { | ||
var continuation = sourceFile.then(function(result) { | ||
var obj = { result: result }; | ||
if (options.inputSha) { obj.inputSha = createHash(result); } | ||
sourceFileContents = result; | ||
// if (options.inputSha) { obj.inputSha = createHash(result); } | ||
return obj; | ||
@@ -199,6 +202,35 @@ }); | ||
continuation.then(function(compiled) { | ||
continuation = continuation.then(function(compiled) { | ||
if (options.minify) { compiled = minify(compiled, options); } | ||
if (options.outputSha) { compiled.outputSha = createHash(compiled.result); } | ||
compiled.transformId = transformId === '' ? null : transformId; | ||
if (options.inputSha) { | ||
var inputSha; | ||
if (compiled.sourcemap) { | ||
inputSha = compiled.sourcemap.sources.map(function(path) { | ||
if (path === pathName) { | ||
return { | ||
file: pathName, | ||
sha: createHash(sourceFileContents) | ||
}; | ||
} else { | ||
return fs.readFile(path, 'utf8').then(function(content) { | ||
return { | ||
file: path, | ||
sha: createHash(content) | ||
}; | ||
}); | ||
} | ||
}); | ||
} else { | ||
inputSha = [{ | ||
file: pathName, | ||
sha: createHash(sourceFileContents) | ||
}]; | ||
} | ||
return when.all(inputSha).then(function(inputSha) { | ||
compiled.inputSha = inputSha; | ||
return compiled; | ||
}); | ||
} | ||
return compiled; | ||
@@ -205,0 +237,0 @@ }); |
{ | ||
"name": "baby-tolk", | ||
"version": "4.5.0", | ||
"version": "5.0.0", | ||
"description": "A file reader that promises to translate non-web assets to web assets given the available transpilers, sourcemaps and all", | ||
@@ -5,0 +5,0 @@ "main": "lib/baby-tolk.js", |
16036
313