Fixed up formatting for transforming.

This commit is contained in:
Richard Moore 2018-06-19 02:13:34 -04:00
parent 5b18a63ebc
commit 1d282c544a
No known key found for this signature in database
GPG Key ID: 525F70A6FCABC295

@ -72,6 +72,11 @@ function transformFile(path) {
return null;
}
function padding(length) {
let pad = '';
while (pad.length < length) { pad += ' '; }
return pad;
}
function transform(path, options) {
var data = '';
@ -79,12 +84,16 @@ function transform(path, options) {
data += chunk;
}, function () {
var transformed = transformFile(path);
var shortPath = path;
if (shortPath.substring(0, __dirname.length) == __dirname) {
shortPath = shortPath.substring(__dirname.length);
}
var size = fs.readFileSync(path).length;
if (transformed != null) {
console.log('Transformed:', path);
console.log('Transformed:', shortPath, padding(70 - shortPath.length), size, padding(6 - String(size).length), '=>', transformed.length);
data = transformed;
} else {
var size = fs.readFileSync(path).length;
console.log('Preserved:', path, size);
console.log('Preserved: ', shortPath, padding(70 - shortPath.length), size);
}
this.queue(data);
this.queue(null);