From eeba22238736ed0832488efb3c515ada98073424 Mon Sep 17 00:00:00 2001 From: Jamie Magee Date: Mon, 19 Jun 2023 21:14:00 -0700 Subject: [PATCH] chore: lint fixes --- test/extract.js | 3 +- test/pack.js | 292 ++++++++++++++++++++++++------------------------ test/parse.js | 2 +- test/update.js | 1 - 4 files changed, 147 insertions(+), 151 deletions(-) diff --git a/test/extract.js b/test/extract.js index b79b91cc..e580db97 100644 --- a/test/extract.js +++ b/test/extract.js @@ -332,8 +332,7 @@ t.test('brotli', async t => { x({ sync: true, file: file, C: dir, brotli: true }) t.same(fs.readdirSync(dir + '/x').sort(), - ['1', '10', '2', '3', '4', '5', '6', '7', '8', '9']) + ['1', '10', '2', '3', '4', '5', '6', '7', '8', '9']) t.end() }) }) - diff --git a/test/pack.js b/test/pack.js index 74158d7f..99c733d3 100644 --- a/test/pack.js +++ b/test/pack.js @@ -376,10 +376,10 @@ t.test('if gzip is truthy, make it an object', t => { }) t.test('if brotli is truthy, make it an object', t => { - const opt = { brotli: true } - new Pack(opt) - t.type(opt.brotli, 'object') - t.end() + const opt = { brotli: true } + new Pack(opt) + t.type(opt.brotli, 'object') + t.end() }) t.test('gzip, also a very deep path', t => { @@ -462,82 +462,81 @@ t.test('gzip, also a very deep path', t => { }) t.test('brotli, also a very deep path', t => { - const out = [] + const out = [] - new Pack({ - cwd: files, - brotli: { flush: 1 }, - }) - .add('dir') - .add('long-path') - .on('data', c => out.push(c)) - .end() - .on('end', _ => { - const zipped = Buffer.concat(out) - const data = zlib.brotliDecompressSync(zipped) - const entries = [] - for (var i = 0; i < data.length; i += 512) { - const slice = data.slice(i, i + 512) - const h = new Header(slice) - if (h.nullBlock) { - entries.push('null block') - } else if (h.cksumValid) { - entries.push([h.type, h.path]) - } else if (entries[entries.length - 1][0] === 'File') { - entries[entries.length - 1].push(slice.toString().replace(/\0.*$/, '')) - } - } - - const expect = [ - ['Directory', 'dir/'], - ['Directory', 'long-path/'], - ['File', 'dir/x'], - ['Directory', 'long-path/r/'], - ['Directory', 'long-path/r/e/'], - ['Directory', 'long-path/r/e/a/'], - ['Directory', 'long-path/r/e/a/l/'], - ['Directory', 'long-path/r/e/a/l/l/'], - ['Directory', 'long-path/r/e/a/l/l/y/'], - ['Directory', 'long-path/r/e/a/l/l/y/-/'], - ['Directory', 'long-path/r/e/a/l/l/y/-/d/'], - ['Directory', 'long-path/r/e/a/l/l/y/-/d/e/'], - ['Directory', 'long-path/r/e/a/l/l/y/-/d/e/e/'], - ['Directory', 'long-path/r/e/a/l/l/y/-/d/e/e/p/'], - ['Directory', 'long-path/r/e/a/l/l/y/-/d/e/e/p/-/'], - ['Directory', 'long-path/r/e/a/l/l/y/-/d/e/e/p/-/f/'], - ['Directory', 'long-path/r/e/a/l/l/y/-/d/e/e/p/-/f/o/'], - ['Directory', 'long-path/r/e/a/l/l/y/-/d/e/e/p/-/f/o/l/'], - ['Directory', 'long-path/r/e/a/l/l/y/-/d/e/e/p/-/f/o/l/d/'], - ['Directory', 'long-path/r/e/a/l/l/y/-/d/e/e/p/-/f/o/l/d/e/'], - ['Directory', 'long-path/r/e/a/l/l/y/-/d/e/e/p/-/f/o/l/d/e/r/'], - ['Directory', 'long-path/r/e/a/l/l/y/-/d/e/e/p/-/f/o/l/d/e/r/-/'], - ['Directory', 'long-path/r/e/a/l/l/y/-/d/e/e/p/-/f/o/l/d/e/r/-/p/'], - ['Directory', 'long-path/r/e/a/l/l/y/-/d/e/e/p/-/f/o/l/d/e/r/-/p/a/'], - ['Directory', 'long-path/r/e/a/l/l/y/-/d/e/e/p/-/f/o/l/d/e/r/-/p/a/t/'], - ['Directory', 'long-path/r/e/a/l/l/y/-/d/e/e/p/-/f/o/l/d/e/r/-/p/a/t/h/'], - ['File', 'long-path/r/e/a/l/l/y/-/d/e/e/p/-/f/o/l/d/e/r/-/p/a/t/h/a.txt', 'short\n'], - ['File', 'long-path/r/e/a/l/l/y/-/d/e/e/p/-/f/o/l/d/e/r/-/p/a/t/h/cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc', '1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111'], - ['ExtendedHeader', 'PaxHeader/ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc'], - ['File', 'long-path/r/e/a/l/l/y/-/d/e/e/p/-/f/o/l/d/e/r/-/p/a/t/h/ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc', '2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222'], - ['ExtendedHeader', 'PaxHeader/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxccccccccccccccccccccccccccccccccccccccc'], - ['File', 'long-path/r/e/a/l/l/y/-/d/e/e/p/-/f/o/l/d/e/r/-/p/a/t/h/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxccccccccccccccccccccccccccccccccccccccccccccccccc', 'cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc'], - ['ExtendedHeader', 'PaxHeader/Ω.txt'], - ['File', 'long-path/r/e/a/l/l/y/-/d/e/e/p/-/f/o/l/d/e/r/-/p/a/t/h/Ω.txt', 'Ω'], - 'null block', - 'null block', - ] - - let ok = true - entries.forEach((entry, i) => { - ok = ok && + new Pack({ + cwd: files, + brotli: { flush: 1 }, + }) + .add('dir') + .add('long-path') + .on('data', c => out.push(c)) + .end() + .on('end', _ => { + const zipped = Buffer.concat(out) + const data = zlib.brotliDecompressSync(zipped) + const entries = [] + for (var i = 0; i < data.length; i += 512) { + const slice = data.slice(i, i + 512) + const h = new Header(slice) + if (h.nullBlock) { + entries.push('null block') + } else if (h.cksumValid) { + entries.push([h.type, h.path]) + } else if (entries[entries.length - 1][0] === 'File') { + entries[entries.length - 1].push(slice.toString().replace(/\0.*$/, '')) + } + } + + const expect = [ + ['Directory', 'dir/'], + ['Directory', 'long-path/'], + ['File', 'dir/x'], + ['Directory', 'long-path/r/'], + ['Directory', 'long-path/r/e/'], + ['Directory', 'long-path/r/e/a/'], + ['Directory', 'long-path/r/e/a/l/'], + ['Directory', 'long-path/r/e/a/l/l/'], + ['Directory', 'long-path/r/e/a/l/l/y/'], + ['Directory', 'long-path/r/e/a/l/l/y/-/'], + ['Directory', 'long-path/r/e/a/l/l/y/-/d/'], + ['Directory', 'long-path/r/e/a/l/l/y/-/d/e/'], + ['Directory', 'long-path/r/e/a/l/l/y/-/d/e/e/'], + ['Directory', 'long-path/r/e/a/l/l/y/-/d/e/e/p/'], + ['Directory', 'long-path/r/e/a/l/l/y/-/d/e/e/p/-/'], + ['Directory', 'long-path/r/e/a/l/l/y/-/d/e/e/p/-/f/'], + ['Directory', 'long-path/r/e/a/l/l/y/-/d/e/e/p/-/f/o/'], + ['Directory', 'long-path/r/e/a/l/l/y/-/d/e/e/p/-/f/o/l/'], + ['Directory', 'long-path/r/e/a/l/l/y/-/d/e/e/p/-/f/o/l/d/'], + ['Directory', 'long-path/r/e/a/l/l/y/-/d/e/e/p/-/f/o/l/d/e/'], + ['Directory', 'long-path/r/e/a/l/l/y/-/d/e/e/p/-/f/o/l/d/e/r/'], + ['Directory', 'long-path/r/e/a/l/l/y/-/d/e/e/p/-/f/o/l/d/e/r/-/'], + ['Directory', 'long-path/r/e/a/l/l/y/-/d/e/e/p/-/f/o/l/d/e/r/-/p/'], + ['Directory', 'long-path/r/e/a/l/l/y/-/d/e/e/p/-/f/o/l/d/e/r/-/p/a/'], + ['Directory', 'long-path/r/e/a/l/l/y/-/d/e/e/p/-/f/o/l/d/e/r/-/p/a/t/'], + ['Directory', 'long-path/r/e/a/l/l/y/-/d/e/e/p/-/f/o/l/d/e/r/-/p/a/t/h/'], + ['File', 'long-path/r/e/a/l/l/y/-/d/e/e/p/-/f/o/l/d/e/r/-/p/a/t/h/a.txt', 'short\n'], + ['File', 'long-path/r/e/a/l/l/y/-/d/e/e/p/-/f/o/l/d/e/r/-/p/a/t/h/cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc', '1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111'], + ['ExtendedHeader', 'PaxHeader/ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc'], + ['File', 'long-path/r/e/a/l/l/y/-/d/e/e/p/-/f/o/l/d/e/r/-/p/a/t/h/ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc', '2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222'], + ['ExtendedHeader', 'PaxHeader/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxccccccccccccccccccccccccccccccccccccccc'], + ['File', 'long-path/r/e/a/l/l/y/-/d/e/e/p/-/f/o/l/d/e/r/-/p/a/t/h/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxccccccccccccccccccccccccccccccccccccccccccccccccc', 'cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc'], + ['ExtendedHeader', 'PaxHeader/Ω.txt'], + ['File', 'long-path/r/e/a/l/l/y/-/d/e/e/p/-/f/o/l/d/e/r/-/p/a/t/h/Ω.txt', 'Ω'], + 'null block', + 'null block', + ] + + let ok = true + entries.forEach((entry, i) => { + ok = ok && t.equal(entry[0], expect[i][0]) && t.equal(entry[1], expect[i][1]) && (!entry[2] || t.equal(entry[2], expect[i][2])) - }) + }) - // t.match(entries, expect) - t.end() - }) + t.end() + }) }) t.test('very deep gzip path, sync', t => { @@ -620,82 +619,81 @@ t.test('very deep gzip path, sync', t => { }) t.test('very deep brotli path, sync', t => { - const pack = new PackSync({ - cwd: files, - brotli: true, - }).add('dir') - .add('long-path') - .end() - - // these do nothing! - pack.pause() - pack.resume() - - const zipped = pack.read() - t.type(zipped, Buffer) - const data = zlib.brotliDecompressSync(zipped) - const entries = [] - for (var i = 0; i < data.length; i += 512) { - const slice = data.slice(i, i + 512) - const h = new Header(slice) - if (h.nullBlock) { - entries.push('null block') - } else if (h.cksumValid) { - entries.push([h.type, h.path]) - } else if (entries[entries.length - 1][0] === 'File') { - entries[entries.length - 1].push(slice.toString().replace(/\0.*$/, '')) - } + const pack = new PackSync({ + cwd: files, + brotli: true, + }).add('dir') + .add('long-path') + .end() + + // these do nothing! + pack.pause() + pack.resume() + + const zipped = pack.read() + t.type(zipped, Buffer) + const data = zlib.brotliDecompressSync(zipped) + const entries = [] + for (var i = 0; i < data.length; i += 512) { + const slice = data.slice(i, i + 512) + const h = new Header(slice) + if (h.nullBlock) { + entries.push('null block') + } else if (h.cksumValid) { + entries.push([h.type, h.path]) + } else if (entries[entries.length - 1][0] === 'File') { + entries[entries.length - 1].push(slice.toString().replace(/\0.*$/, '')) } + } - const expect = [ - ['Directory', 'dir/'], - ['File', 'dir/x'], - ['Directory', 'long-path/'], - ['Directory', 'long-path/r/'], - ['Directory', 'long-path/r/e/'], - ['Directory', 'long-path/r/e/a/'], - ['Directory', 'long-path/r/e/a/l/'], - ['Directory', 'long-path/r/e/a/l/l/'], - ['Directory', 'long-path/r/e/a/l/l/y/'], - ['Directory', 'long-path/r/e/a/l/l/y/-/'], - ['Directory', 'long-path/r/e/a/l/l/y/-/d/'], - ['Directory', 'long-path/r/e/a/l/l/y/-/d/e/'], - ['Directory', 'long-path/r/e/a/l/l/y/-/d/e/e/'], - ['Directory', 'long-path/r/e/a/l/l/y/-/d/e/e/p/'], - ['Directory', 'long-path/r/e/a/l/l/y/-/d/e/e/p/-/'], - ['Directory', 'long-path/r/e/a/l/l/y/-/d/e/e/p/-/f/'], - ['Directory', 'long-path/r/e/a/l/l/y/-/d/e/e/p/-/f/o/'], - ['Directory', 'long-path/r/e/a/l/l/y/-/d/e/e/p/-/f/o/l/'], - ['Directory', 'long-path/r/e/a/l/l/y/-/d/e/e/p/-/f/o/l/d/'], - ['Directory', 'long-path/r/e/a/l/l/y/-/d/e/e/p/-/f/o/l/d/e/'], - ['Directory', 'long-path/r/e/a/l/l/y/-/d/e/e/p/-/f/o/l/d/e/r/'], - ['Directory', 'long-path/r/e/a/l/l/y/-/d/e/e/p/-/f/o/l/d/e/r/-/'], - ['Directory', 'long-path/r/e/a/l/l/y/-/d/e/e/p/-/f/o/l/d/e/r/-/p/'], - ['Directory', 'long-path/r/e/a/l/l/y/-/d/e/e/p/-/f/o/l/d/e/r/-/p/a/'], - ['Directory', 'long-path/r/e/a/l/l/y/-/d/e/e/p/-/f/o/l/d/e/r/-/p/a/t/'], - ['Directory', 'long-path/r/e/a/l/l/y/-/d/e/e/p/-/f/o/l/d/e/r/-/p/a/t/h/'], - ['File', 'long-path/r/e/a/l/l/y/-/d/e/e/p/-/f/o/l/d/e/r/-/p/a/t/h/a.txt', 'short\n'], - ['File', 'long-path/r/e/a/l/l/y/-/d/e/e/p/-/f/o/l/d/e/r/-/p/a/t/h/cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc', '1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111'], - ['ExtendedHeader', 'PaxHeader/ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc'], - ['File', 'long-path/r/e/a/l/l/y/-/d/e/e/p/-/f/o/l/d/e/r/-/p/a/t/h/ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc', '2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222'], - ['ExtendedHeader', 'PaxHeader/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxccccccccccccccccccccccccccccccccccccccc'], - ['File', 'long-path/r/e/a/l/l/y/-/d/e/e/p/-/f/o/l/d/e/r/-/p/a/t/h/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxccccccccccccccccccccccccccccccccccccccccccccccccc', 'cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc'], - ['ExtendedHeader', 'PaxHeader/Ω.txt'], - ['File', 'long-path/r/e/a/l/l/y/-/d/e/e/p/-/f/o/l/d/e/r/-/p/a/t/h/Ω.txt', 'Ω'], - 'null block', - 'null block', - ] + const expect = [ + ['Directory', 'dir/'], + ['File', 'dir/x'], + ['Directory', 'long-path/'], + ['Directory', 'long-path/r/'], + ['Directory', 'long-path/r/e/'], + ['Directory', 'long-path/r/e/a/'], + ['Directory', 'long-path/r/e/a/l/'], + ['Directory', 'long-path/r/e/a/l/l/'], + ['Directory', 'long-path/r/e/a/l/l/y/'], + ['Directory', 'long-path/r/e/a/l/l/y/-/'], + ['Directory', 'long-path/r/e/a/l/l/y/-/d/'], + ['Directory', 'long-path/r/e/a/l/l/y/-/d/e/'], + ['Directory', 'long-path/r/e/a/l/l/y/-/d/e/e/'], + ['Directory', 'long-path/r/e/a/l/l/y/-/d/e/e/p/'], + ['Directory', 'long-path/r/e/a/l/l/y/-/d/e/e/p/-/'], + ['Directory', 'long-path/r/e/a/l/l/y/-/d/e/e/p/-/f/'], + ['Directory', 'long-path/r/e/a/l/l/y/-/d/e/e/p/-/f/o/'], + ['Directory', 'long-path/r/e/a/l/l/y/-/d/e/e/p/-/f/o/l/'], + ['Directory', 'long-path/r/e/a/l/l/y/-/d/e/e/p/-/f/o/l/d/'], + ['Directory', 'long-path/r/e/a/l/l/y/-/d/e/e/p/-/f/o/l/d/e/'], + ['Directory', 'long-path/r/e/a/l/l/y/-/d/e/e/p/-/f/o/l/d/e/r/'], + ['Directory', 'long-path/r/e/a/l/l/y/-/d/e/e/p/-/f/o/l/d/e/r/-/'], + ['Directory', 'long-path/r/e/a/l/l/y/-/d/e/e/p/-/f/o/l/d/e/r/-/p/'], + ['Directory', 'long-path/r/e/a/l/l/y/-/d/e/e/p/-/f/o/l/d/e/r/-/p/a/'], + ['Directory', 'long-path/r/e/a/l/l/y/-/d/e/e/p/-/f/o/l/d/e/r/-/p/a/t/'], + ['Directory', 'long-path/r/e/a/l/l/y/-/d/e/e/p/-/f/o/l/d/e/r/-/p/a/t/h/'], + ['File', 'long-path/r/e/a/l/l/y/-/d/e/e/p/-/f/o/l/d/e/r/-/p/a/t/h/a.txt', 'short\n'], + ['File', 'long-path/r/e/a/l/l/y/-/d/e/e/p/-/f/o/l/d/e/r/-/p/a/t/h/cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc', '1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111'], + ['ExtendedHeader', 'PaxHeader/ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc'], + ['File', 'long-path/r/e/a/l/l/y/-/d/e/e/p/-/f/o/l/d/e/r/-/p/a/t/h/ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc', '2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222'], + ['ExtendedHeader', 'PaxHeader/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxccccccccccccccccccccccccccccccccccccccc'], + ['File', 'long-path/r/e/a/l/l/y/-/d/e/e/p/-/f/o/l/d/e/r/-/p/a/t/h/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxccccccccccccccccccccccccccccccccccccccccccccccccc', 'cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc'], + ['ExtendedHeader', 'PaxHeader/Ω.txt'], + ['File', 'long-path/r/e/a/l/l/y/-/d/e/e/p/-/f/o/l/d/e/r/-/p/a/t/h/Ω.txt', 'Ω'], + 'null block', + 'null block', + ] - let ok = true - entries.forEach((entry, i) => { - ok = ok && - t.equal(entry[0], expect[i][0]) && - t.equal(entry[1], expect[i][1]) && - (!entry[2] || t.equal(entry[2], expect[i][2])) - }) + let ok = true + entries.forEach((entry, i) => { + ok = ok && + t.equal(entry[0], expect[i][0]) && + t.equal(entry[1], expect[i][1]) && + (!entry[2] || t.equal(entry[2], expect[i][2])) + }) - // t.match(entries, expect) - t.end() + t.end() }) t.test('write after end', t => { diff --git a/test/parse.js b/test/parse.js index 0113e7b4..dd74b2c7 100644 --- a/test/parse.js +++ b/test/parse.js @@ -130,7 +130,7 @@ t.test('fixture tests', t => { maxMetaEntrySize: maxMeta, filter: filter ? (path, entry) => entry.size % 2 !== 0 : null, strict: strict, - brotli: {} + brotli: {}, }) trackEvents(t, expect, p) p.end(zlib.brotliCompressSync(tardata)) diff --git a/test/update.js b/test/update.js index ff74c6e5..7034a165 100644 --- a/test/update.js +++ b/test/update.js @@ -9,7 +9,6 @@ const { resolve } = require('path') const fixtures = path.resolve(__dirname, 'fixtures') const tars = path.resolve(fixtures, 'tars') const zlib = require('zlib') -const r = require("../lib/replace"); const spawn = require('child_process').spawn