From 1c4d6004500f81e6775eee31098840277b7e47bf Mon Sep 17 00:00:00 2001 From: Jerko Steiner Date: Wed, 25 Sep 2019 13:46:16 +0700 Subject: [PATCH] Remove scripts/unpack.js in favor of rondo unpack --- scripts/unpack.js | 53 ----------------------------------------------- 1 file changed, 53 deletions(-) delete mode 100755 scripts/unpack.js diff --git a/scripts/unpack.js b/scripts/unpack.js deleted file mode 100755 index a011b8a..0000000 --- a/scripts/unpack.js +++ /dev/null @@ -1,53 +0,0 @@ -#!/usr/bin/env node -const filename = process.argv[2] -const fs = require('fs') -const unpack = require('browser-unpack') -const path = require('path') - -const file = fs.readFileSync(filename, 'utf8') -const result = unpack(file) - -const sizes = result.map(item => { - const size = new Buffer(item.source).byteLength - const sizeKb = (size / 1024).toFixed(3) + ' kb' - return { - id: path.relative(process.cwd(), item.id), - size, - sizeKb, - } -}) -.sort((a, b) => a.size - b.size) - -const maxNameLength = sizes -.reduce((m, i) => m < i.id.length ? i.id.length : m, 0) -const maxSizeLength = sizes -.reduce((m, i) => m < i.sizeKb.length ? i.sizeKb.length : m, 0) - -const totalSize = sizes.reduce((s, i) => i.size + s, 0) - -function padRight(text, size) { - while (text.length < size) { - text += ' ' - } - return text -} - -function padLeft(text, size) { - while (text.length < size) { - text = ' ' + text - } - return text -} - -sizes -.forEach(item => { - console.log( - padRight(item.id, maxNameLength), - padLeft(item.sizeKb, maxSizeLength), - ) -}) -console.log() -console.log( - padRight('Total size:', maxNameLength), - padLeft((totalSize / 1024).toFixed(3) + ' kb', maxSizeLength), -)