From 18a29c1b236b329b105704b4f8e553aa14badbeb Mon Sep 17 00:00:00 2001 From: TxThinking Date: Fri, 19 Apr 2024 10:39:08 +0800 Subject: [PATCH] Update bundle.js --- bundle.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/bundle.js b/bundle.js index dc5dfa7..d962dc1 100644 --- a/bundle.js +++ b/bundle.js @@ -18,19 +18,19 @@ var dir = process.argv[2].endsWith("/") ? process.argv[2].slice(0, -1) : process var output = process.argv.length >= 4 ? process.argv[3] : "bundle.js" var f = await fs.open(output, 'w'); -await fs.write(f, new TextEncoder().encode(`var m = {};\n`)); +await f.write(new TextEncoder().encode(`var m = {};\n`)); var l = await fs.readdir(dir, { recursive: true, withFileTypes: true }) for (var v of l) { if (v.isFile()) { var k = dir + "/" + v.name k = k.replace(dir, path.basename(dir)) - await fs.write(f, new TextEncoder().encode(`m["${k}"] = new Uint8Array([`)); + await f.write(new TextEncoder().encode(`m["${k}"] = new Uint8Array([`)); var b = new Uint8Array(await Bun.file(path.join(dir, v.name)).arrayBuffer()); for (var j = 0; j < b.length; j++) { - await fs.write(f, new TextEncoder().encode(`${b[j]},`)); + await f.write(new TextEncoder().encode(`${b[j]},`)); } - await fs.write(f, new TextEncoder().encode(`]);\n`)); + await f.write(new TextEncoder().encode(`]);\n`)); } } -await fs.write(f, new TextEncoder().encode(`export default function(k){if(m[k]) return m[k]; throw 'NotFound';}\n`)); -await fs.close(f) +await f.write(new TextEncoder().encode(`export default function(k){if(m[k]) return m[k]; throw 'NotFound';}\n`)); +await f.close()