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; return null;
} }
function padding(length) {
let pad = '';
while (pad.length < length) { pad += ' '; }
return pad;
}
function transform(path, options) { function transform(path, options) {
var data = ''; var data = '';
@ -79,12 +84,16 @@ function transform(path, options) {
data += chunk; data += chunk;
}, function () { }, function () {
var transformed = transformFile(path); 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) { 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; data = transformed;
} else { } else {
var size = fs.readFileSync(path).length; console.log('Preserved: ', shortPath, padding(70 - shortPath.length), size);
console.log('Preserved:', path, size);
} }
this.queue(data); this.queue(data);
this.queue(null); this.queue(null);