diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 07fa98dd..cf2a1e57 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,19 +1,29 @@ name: CI on: - push: {} + push: + branches: ["main"] pull_request_target: paths: - 'src/**' - 'test/**' - '*.json' + - '*.js' + - '*.ts' + - 'lib/**' + - 'scripts/**' + - '.github/workflows/ci.yml' + - 'package.json' + workflow_dispatch: +permissions: + contents: read jobs: build: strategy: matrix: - node-version: [22.x, 24.x] + node-version: [22.x, 24.x, 25.x] platform: - os: ubuntu-latest shell: bash @@ -28,10 +38,10 @@ jobs: steps: - name: Checkout Repository - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: Use Nodejs ${{ matrix.node-version }} - uses: actions/setup-node@v4 + uses: actions/setup-node@v6 with: node-version: ${{ matrix.node-version }} diff --git a/.github/workflows/typedoc.yml b/.github/workflows/typedoc.yml index e1a0847c..08af735e 100644 --- a/.github/workflows/typedoc.yml +++ b/.github/workflows/typedoc.yml @@ -1,27 +1,20 @@ -# Simple workflow for deploying static content to GitHub Pages -name: Deploy static content to Pages +name: typedoc on: - # Runs on pushes targeting the default branch push: branches: ["main"] - - # Allows you to run this workflow manually from the Actions tab workflow_dispatch: -# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages permissions: contents: read pages: write id-token: write -# Allow one concurrent deployment concurrency: group: "pages" cancel-in-progress: true jobs: - # Single deploy job since we're just deploying deploy: environment: name: github-pages @@ -29,19 +22,20 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: Use Nodejs ${{ matrix.node-version }} - uses: actions/setup-node@v4 + uses: actions/setup-node@v6 with: node-version: 20.x - name: Install dependencies run: npm install - name: Generate typedocs run: npm run typedoc + - name: Setup Pages - uses: actions/configure-pages@v4 + uses: actions/configure-pages@v5 - name: Upload artifact - uses: actions/upload-pages-artifact@v3 + uses: actions/upload-pages-artifact@v4 with: path: './docs' - name: Deploy to GitHub Pages diff --git a/.prettierignore b/.prettierignore index 8e504889..cf134510 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,4 +1,7 @@ /node_modules +/tsconfig.json +/package-lock.json +/package.json /LICENSE.md /example /.github @@ -12,3 +15,4 @@ /test/fixture /test/fixtures /.tshy +/docs diff --git a/.prettierrc.json b/.prettierrc.json index 29bd039f..02b40d2a 100644 --- a/.prettierrc.json +++ b/.prettierrc.json @@ -1,7 +1,7 @@ { "experimentalTernaries": true, "semi": false, - "printWidth": 70, + "printWidth": 75, "tabWidth": 2, "useTabs": false, "singleQuote": true, diff --git a/package-lock.json b/package-lock.json index b30999b6..bbd2f6e1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,13 +16,15 @@ "yallist": "^5.0.0" }, "devDependencies": { - "@types/node": "^25.3.3", + "@types/node": "^25.5.0", "chmodr": "^2.0.2", "end-of-stream": "^1.4.3", - "esbuild": "^0.27.3", + "esbuild": "^0.27.4", "events-to-array": "^2.0.3", "mutate-fs": "^2.1.1", "nock": "^13.5.4", + "oxlint": "^1.56.0", + "oxlint-tsgolint": "^0.17.0", "prettier": "^3.8.1", "rimraf": "^6.1.2", "tap": "^21.6.2", @@ -78,9 +80,9 @@ } }, "node_modules/@esbuild/aix-ppc64": { - "version": "0.27.3", - "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.27.3.tgz", - "integrity": "sha512-9fJMTNFTWZMh5qwrBItuziu834eOCUcEqymSH7pY+zoMVEZg3gcPuBNxH1EvfVYe9h0x/Ptw8KBzv7qxb7l8dg==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.27.4.tgz", + "integrity": "sha512-cQPwL2mp2nSmHHJlCyoXgHGhbEPMrEEU5xhkcy3Hs/O7nGZqEpZ2sUtLaL9MORLtDfRvVl2/3PAuEkYZH0Ty8Q==", "cpu": [ "ppc64" ], @@ -95,9 +97,9 @@ } }, "node_modules/@esbuild/android-arm": { - "version": "0.27.3", - "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.27.3.tgz", - "integrity": "sha512-i5D1hPY7GIQmXlXhs2w8AWHhenb00+GxjxRncS2ZM7YNVGNfaMxgzSGuO8o8SJzRc/oZwU2bcScvVERk03QhzA==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.27.4.tgz", + "integrity": "sha512-X9bUgvxiC8CHAGKYufLIHGXPJWnr0OCdR0anD2e21vdvgCI8lIfqFbnoeOz7lBjdrAGUhqLZLcQo6MLhTO2DKQ==", "cpu": [ "arm" ], @@ -112,9 +114,9 @@ } }, "node_modules/@esbuild/android-arm64": { - "version": "0.27.3", - "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.27.3.tgz", - "integrity": "sha512-YdghPYUmj/FX2SYKJ0OZxf+iaKgMsKHVPF1MAq/P8WirnSpCStzKJFjOjzsW0QQ7oIAiccHdcqjbHmJxRb/dmg==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.27.4.tgz", + "integrity": "sha512-gdLscB7v75wRfu7QSm/zg6Rx29VLdy9eTr2t44sfTW7CxwAtQghZ4ZnqHk3/ogz7xao0QAgrkradbBzcqFPasw==", "cpu": [ "arm64" ], @@ -129,9 +131,9 @@ } }, "node_modules/@esbuild/android-x64": { - "version": "0.27.3", - "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.27.3.tgz", - "integrity": "sha512-IN/0BNTkHtk8lkOM8JWAYFg4ORxBkZQf9zXiEOfERX/CzxW3Vg1ewAhU7QSWQpVIzTW+b8Xy+lGzdYXV6UZObQ==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.27.4.tgz", + "integrity": "sha512-PzPFnBNVF292sfpfhiyiXCGSn9HZg5BcAz+ivBuSsl6Rk4ga1oEXAamhOXRFyMcjwr2DVtm40G65N3GLeH1Lvw==", "cpu": [ "x64" ], @@ -146,9 +148,9 @@ } }, "node_modules/@esbuild/darwin-arm64": { - "version": "0.27.3", - "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.27.3.tgz", - "integrity": "sha512-Re491k7ByTVRy0t3EKWajdLIr0gz2kKKfzafkth4Q8A5n1xTHrkqZgLLjFEHVD+AXdUGgQMq+Godfq45mGpCKg==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.27.4.tgz", + "integrity": "sha512-b7xaGIwdJlht8ZFCvMkpDN6uiSmnxxK56N2GDTMYPr2/gzvfdQN8rTfBsvVKmIVY/X7EM+/hJKEIbbHs9oA4tQ==", "cpu": [ "arm64" ], @@ -163,9 +165,9 @@ } }, "node_modules/@esbuild/darwin-x64": { - "version": "0.27.3", - "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.27.3.tgz", - "integrity": "sha512-vHk/hA7/1AckjGzRqi6wbo+jaShzRowYip6rt6q7VYEDX4LEy1pZfDpdxCBnGtl+A5zq8iXDcyuxwtv3hNtHFg==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.27.4.tgz", + "integrity": "sha512-sR+OiKLwd15nmCdqpXMnuJ9W2kpy0KigzqScqHI3Hqwr7IXxBp3Yva+yJwoqh7rE8V77tdoheRYataNKL4QrPw==", "cpu": [ "x64" ], @@ -180,9 +182,9 @@ } }, "node_modules/@esbuild/freebsd-arm64": { - "version": "0.27.3", - "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.27.3.tgz", - "integrity": "sha512-ipTYM2fjt3kQAYOvo6vcxJx3nBYAzPjgTCk7QEgZG8AUO3ydUhvelmhrbOheMnGOlaSFUoHXB6un+A7q4ygY9w==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.27.4.tgz", + "integrity": "sha512-jnfpKe+p79tCnm4GVav68A7tUFeKQwQyLgESwEAUzyxk/TJr4QdGog9sqWNcUbr/bZt/O/HXouspuQDd9JxFSw==", "cpu": [ "arm64" ], @@ -197,9 +199,9 @@ } }, "node_modules/@esbuild/freebsd-x64": { - "version": "0.27.3", - "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.27.3.tgz", - "integrity": "sha512-dDk0X87T7mI6U3K9VjWtHOXqwAMJBNN2r7bejDsc+j03SEjtD9HrOl8gVFByeM0aJksoUuUVU9TBaZa2rgj0oA==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.27.4.tgz", + "integrity": "sha512-2kb4ceA/CpfUrIcTUl1wrP/9ad9Atrp5J94Lq69w7UwOMolPIGrfLSvAKJp0RTvkPPyn6CIWrNy13kyLikZRZQ==", "cpu": [ "x64" ], @@ -214,9 +216,9 @@ } }, "node_modules/@esbuild/linux-arm": { - "version": "0.27.3", - "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.27.3.tgz", - "integrity": "sha512-s6nPv2QkSupJwLYyfS+gwdirm0ukyTFNl3KTgZEAiJDd+iHZcbTPPcWCcRYH+WlNbwChgH2QkE9NSlNrMT8Gfw==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.27.4.tgz", + "integrity": "sha512-aBYgcIxX/wd5n2ys0yESGeYMGF+pv6g0DhZr3G1ZG4jMfruU9Tl1i2Z+Wnj9/KjGz1lTLCcorqE2viePZqj4Eg==", "cpu": [ "arm" ], @@ -231,9 +233,9 @@ } }, "node_modules/@esbuild/linux-arm64": { - "version": "0.27.3", - "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.27.3.tgz", - "integrity": "sha512-sZOuFz/xWnZ4KH3YfFrKCf1WyPZHakVzTiqji3WDc0BCl2kBwiJLCXpzLzUBLgmp4veFZdvN5ChW4Eq/8Fc2Fg==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.27.4.tgz", + "integrity": "sha512-7nQOttdzVGth1iz57kxg9uCz57dxQLHWxopL6mYuYthohPKEK0vU0C3O21CcBK6KDlkYVcnDXY099HcCDXd9dA==", "cpu": [ "arm64" ], @@ -248,9 +250,9 @@ } }, "node_modules/@esbuild/linux-ia32": { - "version": "0.27.3", - "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.27.3.tgz", - "integrity": "sha512-yGlQYjdxtLdh0a3jHjuwOrxQjOZYD/C9PfdbgJJF3TIZWnm/tMd/RcNiLngiu4iwcBAOezdnSLAwQDPqTmtTYg==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.27.4.tgz", + "integrity": "sha512-oPtixtAIzgvzYcKBQM/qZ3R+9TEUd1aNJQu0HhGyqtx6oS7qTpvjheIWBbes4+qu1bNlo2V4cbkISr8q6gRBFA==", "cpu": [ "ia32" ], @@ -265,9 +267,9 @@ } }, "node_modules/@esbuild/linux-loong64": { - "version": "0.27.3", - "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.27.3.tgz", - "integrity": "sha512-WO60Sn8ly3gtzhyjATDgieJNet/KqsDlX5nRC5Y3oTFcS1l0KWba+SEa9Ja1GfDqSF1z6hif/SkpQJbL63cgOA==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.27.4.tgz", + "integrity": "sha512-8mL/vh8qeCoRcFH2nM8wm5uJP+ZcVYGGayMavi8GmRJjuI3g1v6Z7Ni0JJKAJW+m0EtUuARb6Lmp4hMjzCBWzA==", "cpu": [ "loong64" ], @@ -282,9 +284,9 @@ } }, "node_modules/@esbuild/linux-mips64el": { - "version": "0.27.3", - "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.27.3.tgz", - "integrity": "sha512-APsymYA6sGcZ4pD6k+UxbDjOFSvPWyZhjaiPyl/f79xKxwTnrn5QUnXR5prvetuaSMsb4jgeHewIDCIWljrSxw==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.27.4.tgz", + "integrity": "sha512-1RdrWFFiiLIW7LQq9Q2NES+HiD4NyT8Itj9AUeCl0IVCA459WnPhREKgwrpaIfTOe+/2rdntisegiPWn/r/aAw==", "cpu": [ "mips64el" ], @@ -299,9 +301,9 @@ } }, "node_modules/@esbuild/linux-ppc64": { - "version": "0.27.3", - "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.27.3.tgz", - "integrity": "sha512-eizBnTeBefojtDb9nSh4vvVQ3V9Qf9Df01PfawPcRzJH4gFSgrObw+LveUyDoKU3kxi5+9RJTCWlj4FjYXVPEA==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.27.4.tgz", + "integrity": "sha512-tLCwNG47l3sd9lpfyx9LAGEGItCUeRCWeAx6x2Jmbav65nAwoPXfewtAdtbtit/pJFLUWOhpv0FpS6GQAmPrHA==", "cpu": [ "ppc64" ], @@ -316,9 +318,9 @@ } }, "node_modules/@esbuild/linux-riscv64": { - "version": "0.27.3", - "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.27.3.tgz", - "integrity": "sha512-3Emwh0r5wmfm3ssTWRQSyVhbOHvqegUDRd0WhmXKX2mkHJe1SFCMJhagUleMq+Uci34wLSipf8Lagt4LlpRFWQ==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.27.4.tgz", + "integrity": "sha512-BnASypppbUWyqjd1KIpU4AUBiIhVr6YlHx/cnPgqEkNoVOhHg+YiSVxM1RLfiy4t9cAulbRGTNCKOcqHrEQLIw==", "cpu": [ "riscv64" ], @@ -333,9 +335,9 @@ } }, "node_modules/@esbuild/linux-s390x": { - "version": "0.27.3", - "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.27.3.tgz", - "integrity": "sha512-pBHUx9LzXWBc7MFIEEL0yD/ZVtNgLytvx60gES28GcWMqil8ElCYR4kvbV2BDqsHOvVDRrOxGySBM9Fcv744hw==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.27.4.tgz", + "integrity": "sha512-+eUqgb/Z7vxVLezG8bVB9SfBie89gMueS+I0xYh2tJdw3vqA/0ImZJ2ROeWwVJN59ihBeZ7Tu92dF/5dy5FttA==", "cpu": [ "s390x" ], @@ -350,9 +352,9 @@ } }, "node_modules/@esbuild/linux-x64": { - "version": "0.27.3", - "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.27.3.tgz", - "integrity": "sha512-Czi8yzXUWIQYAtL/2y6vogER8pvcsOsk5cpwL4Gk5nJqH5UZiVByIY8Eorm5R13gq+DQKYg0+JyQoytLQas4dA==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.27.4.tgz", + "integrity": "sha512-S5qOXrKV8BQEzJPVxAwnryi2+Iq5pB40gTEIT69BQONqR7JH1EPIcQ/Uiv9mCnn05jff9umq/5nqzxlqTOg9NA==", "cpu": [ "x64" ], @@ -367,9 +369,9 @@ } }, "node_modules/@esbuild/netbsd-arm64": { - "version": "0.27.3", - "resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.27.3.tgz", - "integrity": "sha512-sDpk0RgmTCR/5HguIZa9n9u+HVKf40fbEUt+iTzSnCaGvY9kFP0YKBWZtJaraonFnqef5SlJ8/TiPAxzyS+UoA==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.27.4.tgz", + "integrity": "sha512-xHT8X4sb0GS8qTqiwzHqpY00C95DPAq7nAwX35Ie/s+LO9830hrMd3oX0ZMKLvy7vsonee73x0lmcdOVXFzd6Q==", "cpu": [ "arm64" ], @@ -384,9 +386,9 @@ } }, "node_modules/@esbuild/netbsd-x64": { - "version": "0.27.3", - "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.27.3.tgz", - "integrity": "sha512-P14lFKJl/DdaE00LItAukUdZO5iqNH7+PjoBm+fLQjtxfcfFE20Xf5CrLsmZdq5LFFZzb5JMZ9grUwvtVYzjiA==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.27.4.tgz", + "integrity": "sha512-RugOvOdXfdyi5Tyv40kgQnI0byv66BFgAqjdgtAKqHoZTbTF2QqfQrFwa7cHEORJf6X2ht+l9ABLMP0dnKYsgg==", "cpu": [ "x64" ], @@ -401,9 +403,9 @@ } }, "node_modules/@esbuild/openbsd-arm64": { - "version": "0.27.3", - "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.27.3.tgz", - "integrity": "sha512-AIcMP77AvirGbRl/UZFTq5hjXK+2wC7qFRGoHSDrZ5v5b8DK/GYpXW3CPRL53NkvDqb9D+alBiC/dV0Fb7eJcw==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.27.4.tgz", + "integrity": "sha512-2MyL3IAaTX+1/qP0O1SwskwcwCoOI4kV2IBX1xYnDDqthmq5ArrW94qSIKCAuRraMgPOmG0RDTA74mzYNQA9ow==", "cpu": [ "arm64" ], @@ -418,9 +420,9 @@ } }, "node_modules/@esbuild/openbsd-x64": { - "version": "0.27.3", - "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.27.3.tgz", - "integrity": "sha512-DnW2sRrBzA+YnE70LKqnM3P+z8vehfJWHXECbwBmH/CU51z6FiqTQTHFenPlHmo3a8UgpLyH3PT+87OViOh1AQ==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.27.4.tgz", + "integrity": "sha512-u8fg/jQ5aQDfsnIV6+KwLOf1CmJnfu1ShpwqdwC0uA7ZPwFws55Ngc12vBdeUdnuWoQYx/SOQLGDcdlfXhYmXQ==", "cpu": [ "x64" ], @@ -435,9 +437,9 @@ } }, "node_modules/@esbuild/openharmony-arm64": { - "version": "0.27.3", - "resolved": "https://registry.npmjs.org/@esbuild/openharmony-arm64/-/openharmony-arm64-0.27.3.tgz", - "integrity": "sha512-NinAEgr/etERPTsZJ7aEZQvvg/A6IsZG/LgZy+81wON2huV7SrK3e63dU0XhyZP4RKGyTm7aOgmQk0bGp0fy2g==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/openharmony-arm64/-/openharmony-arm64-0.27.4.tgz", + "integrity": "sha512-JkTZrl6VbyO8lDQO3yv26nNr2RM2yZzNrNHEsj9bm6dOwwu9OYN28CjzZkH57bh4w0I2F7IodpQvUAEd1mbWXg==", "cpu": [ "arm64" ], @@ -452,9 +454,9 @@ } }, "node_modules/@esbuild/sunos-x64": { - "version": "0.27.3", - "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.27.3.tgz", - "integrity": "sha512-PanZ+nEz+eWoBJ8/f8HKxTTD172SKwdXebZ0ndd953gt1HRBbhMsaNqjTyYLGLPdoWHy4zLU7bDVJztF5f3BHA==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.27.4.tgz", + "integrity": "sha512-/gOzgaewZJfeJTlsWhvUEmUG4tWEY2Spp5M20INYRg2ZKl9QPO3QEEgPeRtLjEWSW8FilRNacPOg8R1uaYkA6g==", "cpu": [ "x64" ], @@ -469,9 +471,9 @@ } }, "node_modules/@esbuild/win32-arm64": { - "version": "0.27.3", - "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.27.3.tgz", - "integrity": "sha512-B2t59lWWYrbRDw/tjiWOuzSsFh1Y/E95ofKz7rIVYSQkUYBjfSgf6oeYPNWHToFRr2zx52JKApIcAS/D5TUBnA==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.27.4.tgz", + "integrity": "sha512-Z9SExBg2y32smoDQdf1HRwHRt6vAHLXcxD2uGgO/v2jK7Y718Ix4ndsbNMU/+1Qiem9OiOdaqitioZwxivhXYg==", "cpu": [ "arm64" ], @@ -486,9 +488,9 @@ } }, "node_modules/@esbuild/win32-ia32": { - "version": "0.27.3", - "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.27.3.tgz", - "integrity": "sha512-QLKSFeXNS8+tHW7tZpMtjlNb7HKau0QDpwm49u0vUp9y1WOF+PEzkU84y9GqYaAVW8aH8f3GcBck26jh54cX4Q==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.27.4.tgz", + "integrity": "sha512-DAyGLS0Jz5G5iixEbMHi5KdiApqHBWMGzTtMiJ72ZOLhbu/bzxgAe8Ue8CTS3n3HbIUHQz/L51yMdGMeoxXNJw==", "cpu": [ "ia32" ], @@ -503,9 +505,9 @@ } }, "node_modules/@esbuild/win32-x64": { - "version": "0.27.3", - "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.27.3.tgz", - "integrity": "sha512-4uJGhsxuptu3OcpVAzli+/gWusVGwZZHTlS63hh++ehExkVT8SgiEf7/uC/PclrPPkLhZqGgCTjd0VWLo6xMqA==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.27.4.tgz", + "integrity": "sha512-+knoa0BDoeXgkNvvV1vvbZX4+hizelrkwmGJBdT17t8FNPwG2lKemmuMZlmaNQ3ws3DKKCxpb4zRZEIp3UxFCg==", "cpu": [ "x64" ], @@ -806,6 +808,413 @@ "node": "^20.17.0 || >=22.9.0" } }, + "node_modules/@oxlint-tsgolint/darwin-arm64": { + "version": "0.17.0", + "resolved": "https://registry.npmjs.org/@oxlint-tsgolint/darwin-arm64/-/darwin-arm64-0.17.0.tgz", + "integrity": "sha512-z3XwCDuOAKgk7bO4y5tyH8Zogwr51G56R0XGKC3tlAbrAq8DecoxAd3qhRZqWBMG2Gzl5bWU3Ghu7lrxuLPzYw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@oxlint-tsgolint/darwin-x64": { + "version": "0.17.0", + "resolved": "https://registry.npmjs.org/@oxlint-tsgolint/darwin-x64/-/darwin-x64-0.17.0.tgz", + "integrity": "sha512-TZgVXy0MtI8nt0MYiceuZhHPwHcwlIZ/YwzFTAKrgdHiTvVzFbqHVdXi5wbZfT/o1nHGw9fbGWPlb6qKZ4uZ9Q==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@oxlint-tsgolint/linux-arm64": { + "version": "0.17.0", + "resolved": "https://registry.npmjs.org/@oxlint-tsgolint/linux-arm64/-/linux-arm64-0.17.0.tgz", + "integrity": "sha512-IDfhFl/Y8bjidCvAP6QAxVyBsl78TmfCHlfjtEv2XtJXgYmIwzv6muO18XMp74SZ2qAyD4y2n2dUedrmghGHeA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@oxlint-tsgolint/linux-x64": { + "version": "0.17.0", + "resolved": "https://registry.npmjs.org/@oxlint-tsgolint/linux-x64/-/linux-x64-0.17.0.tgz", + "integrity": "sha512-Bgdgqx/m8EnfjmmlRLEeYy9Yhdt1GdFrMr5mTu/NyLRGkB1C9VLAikdxB7U9QambAGTAmjMbHNFDFk8Vx69Huw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@oxlint-tsgolint/win32-arm64": { + "version": "0.17.0", + "resolved": "https://registry.npmjs.org/@oxlint-tsgolint/win32-arm64/-/win32-arm64-0.17.0.tgz", + "integrity": "sha512-dO6wyKMDqFWh1vwr+zNZS7/ovlfGgl4S3P1LDy4CKjP6V6NGtdmEwWkWax8j/I8RzGZdfXKnoUfb/qhVg5bx0w==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@oxlint-tsgolint/win32-x64": { + "version": "0.17.0", + "resolved": "https://registry.npmjs.org/@oxlint-tsgolint/win32-x64/-/win32-x64-0.17.0.tgz", + "integrity": "sha512-lPGYFp3yX2nh6hLTpIuMnJbZnt3Df42VkoA/fSkMYi2a/LXdDytQGpgZOrb5j47TICARd34RauKm0P3OA4Oxbw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@oxlint/binding-android-arm-eabi": { + "version": "1.56.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-android-arm-eabi/-/binding-android-arm-eabi-1.56.0.tgz", + "integrity": "sha512-IyfYPthZyiSKwAv/dLjeO18SaK8MxLI9Yss2JrRDyweQAkuL3LhEy7pwIwI7uA3KQc1Vdn20kdmj3q0oUIQL6A==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-android-arm64": { + "version": "1.56.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-android-arm64/-/binding-android-arm64-1.56.0.tgz", + "integrity": "sha512-Ga5zYrzH6vc/VFxhn6MmyUnYEfy9vRpwTIks99mY3j6Nz30yYpIkWryI0QKPCgvGUtDSXVLEaMum5nA+WrNOSg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-darwin-arm64": { + "version": "1.56.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-darwin-arm64/-/binding-darwin-arm64-1.56.0.tgz", + "integrity": "sha512-ogmbdJysnw/D4bDcpf1sPLpFThZ48lYp4aKYm10Z/6Nh1SON6NtnNhTNOlhEY296tDFItsZUz+2tgcSYqh8Eyw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-darwin-x64": { + "version": "1.56.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-darwin-x64/-/binding-darwin-x64-1.56.0.tgz", + "integrity": "sha512-x8QE1h+RAtQ2g+3KPsP6Fk/tdz6zJQUv5c7fTrJxXV3GHOo+Ry5p/PsogU4U+iUZg0rj6hS+E4xi+mnwwlDCWQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-freebsd-x64": { + "version": "1.56.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-freebsd-x64/-/binding-freebsd-x64-1.56.0.tgz", + "integrity": "sha512-6G+WMZvwJpMvY7my+/SHEjb7BTk/PFbePqLpmVmUJRIsJMy/UlyYqjpuh0RCgYYkPLcnXm1rUM04kbTk8yS1Yg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-linux-arm-gnueabihf": { + "version": "1.56.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-linux-arm-gnueabihf/-/binding-linux-arm-gnueabihf-1.56.0.tgz", + "integrity": "sha512-YYHBsk/sl7fYwQOok+6W5lBPeUEvisznV/HZD2IfZmF3Bns6cPC3Z0vCtSEOaAWTjYWN3jVsdu55jMxKlsdlhg==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-linux-arm-musleabihf": { + "version": "1.56.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-linux-arm-musleabihf/-/binding-linux-arm-musleabihf-1.56.0.tgz", + "integrity": "sha512-+AZK8rOUr78y8WT6XkDb04IbMRqauNV+vgT6f8ZLOH8wnpQ9i7Nol0XLxAu+Cq7Sb+J9wC0j6Km5hG8rj47/yQ==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-linux-arm64-gnu": { + "version": "1.56.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-linux-arm64-gnu/-/binding-linux-arm64-gnu-1.56.0.tgz", + "integrity": "sha512-urse2SnugwJRojUkGSSeH2LPMaje5Q50yQtvtL9HFckiyeqXzoFwOAZqD5TR29R2lq7UHidfFDM9EGcchcbb8A==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-linux-arm64-musl": { + "version": "1.56.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-linux-arm64-musl/-/binding-linux-arm64-musl-1.56.0.tgz", + "integrity": "sha512-rkTZkBfJ4TYLjansjSzL6mgZOdN5IvUnSq3oNJSLwBcNvy3dlgQtpHPrRxrCEbbcp7oQ6If0tkNaqfOsphYZ9g==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-linux-ppc64-gnu": { + "version": "1.56.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-linux-ppc64-gnu/-/binding-linux-ppc64-gnu-1.56.0.tgz", + "integrity": "sha512-uqL1kMH3u69/e1CH2EJhP3CP28jw2ExLsku4o8RVAZ7fySo9zOyI2fy9pVlTAp4voBLVgzndXi3SgtdyCTa2aA==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-linux-riscv64-gnu": { + "version": "1.56.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-linux-riscv64-gnu/-/binding-linux-riscv64-gnu-1.56.0.tgz", + "integrity": "sha512-j0CcMBOgV6KsRaBdsebIeiy7hCjEvq2KdEsiULf2LZqAq0v1M1lWjelhCV57LxsqaIGChXFuFJ0RiFrSRHPhSg==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-linux-riscv64-musl": { + "version": "1.56.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-linux-riscv64-musl/-/binding-linux-riscv64-musl-1.56.0.tgz", + "integrity": "sha512-7VDOiL8cDG3DQ/CY3yKjbV1c4YPvc4vH8qW09Vv+5ukq3l/Kcyr6XGCd5NvxUmxqDb2vjMpM+eW/4JrEEsUetA==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-linux-s390x-gnu": { + "version": "1.56.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-linux-s390x-gnu/-/binding-linux-s390x-gnu-1.56.0.tgz", + "integrity": "sha512-JGRpX0M+ikD3WpwJ7vKcHKV6Kg0dT52BW2Eu2BupXotYeqGXBrbY+QPkAyKO6MNgKozyTNaRh3r7g+VWgyAQYQ==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-linux-x64-gnu": { + "version": "1.56.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-linux-x64-gnu/-/binding-linux-x64-gnu-1.56.0.tgz", + "integrity": "sha512-dNaICPvtmuxFP/VbqdofrLqdS3bM/AKJN3LMJD52si44ea7Be1cBk6NpfIahaysG9Uo+L98QKddU9CD5L8UHnQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-linux-x64-musl": { + "version": "1.56.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-linux-x64-musl/-/binding-linux-x64-musl-1.56.0.tgz", + "integrity": "sha512-pF1vOtM+GuXmbklM1hV8WMsn6tCNPvkUzklj/Ej98JhlanbmA2RB1BILgOpwSuCTRTIYx2MXssmEyQQ90QF5aA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-openharmony-arm64": { + "version": "1.56.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-openharmony-arm64/-/binding-openharmony-arm64-1.56.0.tgz", + "integrity": "sha512-bp8NQ4RE6fDIFLa4bdBiOA+TAvkNkg+rslR+AvvjlLTYXLy9/uKAYLQudaQouWihLD/hgkrXIKKzXi5IXOewwg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-win32-arm64-msvc": { + "version": "1.56.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-win32-arm64-msvc/-/binding-win32-arm64-msvc-1.56.0.tgz", + "integrity": "sha512-PxT4OJDfMOQBzo3OlzFb9gkoSD+n8qSBxyVq2wQSZIHFQYGEqIRTo9M0ZStvZm5fdhMqaVYpOnJvH2hUMEDk/g==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-win32-ia32-msvc": { + "version": "1.56.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-win32-ia32-msvc/-/binding-win32-ia32-msvc-1.56.0.tgz", + "integrity": "sha512-PTRy6sIEPqy2x8PTP1baBNReN/BNEFmde0L+mYeHmjXE1Vlcc9+I5nsqENsB2yAm5wLkzPoTNCMY/7AnabT4/A==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxlint/binding-win32-x64-msvc": { + "version": "1.56.0", + "resolved": "https://registry.npmjs.org/@oxlint/binding-win32-x64-msvc/-/binding-win32-x64-msvc-1.56.0.tgz", + "integrity": "sha512-ZHa0clocjLmIDr+1LwoWtxRcoYniAvERotvwKUYKhH41NVfl0Y4LNbyQkwMZzwDvKklKGvGZ5+DAG58/Ik47tQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, "node_modules/@pkgjs/parseargs": { "version": "0.11.0", "resolved": "https://registry.npmjs.org/@pkgjs/parseargs/-/parseargs-0.11.0.tgz", @@ -1509,9 +1918,9 @@ "license": "MIT" }, "node_modules/@types/node": { - "version": "25.3.3", - "resolved": "https://registry.npmjs.org/@types/node/-/node-25.3.3.tgz", - "integrity": "sha512-DpzbrH7wIcBaJibpKo9nnSQL0MTRdnWttGyE5haGwK86xgMOkFLp7vEyfQPGLOJh5wNYiJ3V9PmUMDhV9u8kkQ==", + "version": "25.5.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-25.5.0.tgz", + "integrity": "sha512-jp2P3tQMSxWugkCUKLRPVUpGaL5MVFwF8RDuSRztfwgN1wmqJeMSbKlnEtQqU8UrhTmzEmZdu2I6v2dpp7XIxw==", "dev": true, "license": "MIT", "dependencies": { @@ -2274,9 +2683,9 @@ ] }, "node_modules/esbuild": { - "version": "0.27.3", - "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.27.3.tgz", - "integrity": "sha512-8VwMnyGCONIs6cWue2IdpHxHnAjzxnw2Zr7MkVxB2vjmQ2ivqGFb4LEG3SMnv0Gb2F/G/2yA8zUaiL1gywDCCg==", + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.27.4.tgz", + "integrity": "sha512-Rq4vbHnYkK5fws5NF7MYTU68FPRE1ajX7heQ/8QXXWqNgqqJ/GkmmyxIzUnf2Sr/bakf8l54716CcMGHYhMrrQ==", "dev": true, "hasInstallScript": true, "license": "MIT", @@ -2287,32 +2696,32 @@ "node": ">=18" }, "optionalDependencies": { - "@esbuild/aix-ppc64": "0.27.3", - "@esbuild/android-arm": "0.27.3", - "@esbuild/android-arm64": "0.27.3", - "@esbuild/android-x64": "0.27.3", - "@esbuild/darwin-arm64": "0.27.3", - "@esbuild/darwin-x64": "0.27.3", - "@esbuild/freebsd-arm64": "0.27.3", - "@esbuild/freebsd-x64": "0.27.3", - "@esbuild/linux-arm": "0.27.3", - "@esbuild/linux-arm64": "0.27.3", - "@esbuild/linux-ia32": "0.27.3", - "@esbuild/linux-loong64": "0.27.3", - "@esbuild/linux-mips64el": "0.27.3", - "@esbuild/linux-ppc64": "0.27.3", - "@esbuild/linux-riscv64": "0.27.3", - "@esbuild/linux-s390x": "0.27.3", - "@esbuild/linux-x64": "0.27.3", - "@esbuild/netbsd-arm64": "0.27.3", - "@esbuild/netbsd-x64": "0.27.3", - "@esbuild/openbsd-arm64": "0.27.3", - "@esbuild/openbsd-x64": "0.27.3", - "@esbuild/openharmony-arm64": "0.27.3", - "@esbuild/sunos-x64": "0.27.3", - "@esbuild/win32-arm64": "0.27.3", - "@esbuild/win32-ia32": "0.27.3", - "@esbuild/win32-x64": "0.27.3" + "@esbuild/aix-ppc64": "0.27.4", + "@esbuild/android-arm": "0.27.4", + "@esbuild/android-arm64": "0.27.4", + "@esbuild/android-x64": "0.27.4", + "@esbuild/darwin-arm64": "0.27.4", + "@esbuild/darwin-x64": "0.27.4", + "@esbuild/freebsd-arm64": "0.27.4", + "@esbuild/freebsd-x64": "0.27.4", + "@esbuild/linux-arm": "0.27.4", + "@esbuild/linux-arm64": "0.27.4", + "@esbuild/linux-ia32": "0.27.4", + "@esbuild/linux-loong64": "0.27.4", + "@esbuild/linux-mips64el": "0.27.4", + "@esbuild/linux-ppc64": "0.27.4", + "@esbuild/linux-riscv64": "0.27.4", + "@esbuild/linux-s390x": "0.27.4", + "@esbuild/linux-x64": "0.27.4", + "@esbuild/netbsd-arm64": "0.27.4", + "@esbuild/netbsd-x64": "0.27.4", + "@esbuild/openbsd-arm64": "0.27.4", + "@esbuild/openbsd-x64": "0.27.4", + "@esbuild/openharmony-arm64": "0.27.4", + "@esbuild/sunos-x64": "0.27.4", + "@esbuild/win32-arm64": "0.27.4", + "@esbuild/win32-ia32": "0.27.4", + "@esbuild/win32-x64": "0.27.4" } }, "node_modules/escalade": { @@ -3366,6 +3775,69 @@ "opener": "bin/opener-bin.js" } }, + "node_modules/oxlint": { + "version": "1.56.0", + "resolved": "https://registry.npmjs.org/oxlint/-/oxlint-1.56.0.tgz", + "integrity": "sha512-Q+5Mj5PVaH/R6/fhMMFzw4dT+KPB+kQW4kaL8FOIq7tfhlnEVp6+3lcWqFruuTNlUo9srZUW3qH7Id4pskeR6g==", + "dev": true, + "license": "MIT", + "bin": { + "oxlint": "bin/oxlint" + }, + "engines": { + "node": "^20.19.0 || >=22.12.0" + }, + "funding": { + "url": "https://github.com/sponsors/Boshen" + }, + "optionalDependencies": { + "@oxlint/binding-android-arm-eabi": "1.56.0", + "@oxlint/binding-android-arm64": "1.56.0", + "@oxlint/binding-darwin-arm64": "1.56.0", + "@oxlint/binding-darwin-x64": "1.56.0", + "@oxlint/binding-freebsd-x64": "1.56.0", + "@oxlint/binding-linux-arm-gnueabihf": "1.56.0", + "@oxlint/binding-linux-arm-musleabihf": "1.56.0", + "@oxlint/binding-linux-arm64-gnu": "1.56.0", + "@oxlint/binding-linux-arm64-musl": "1.56.0", + "@oxlint/binding-linux-ppc64-gnu": "1.56.0", + "@oxlint/binding-linux-riscv64-gnu": "1.56.0", + "@oxlint/binding-linux-riscv64-musl": "1.56.0", + "@oxlint/binding-linux-s390x-gnu": "1.56.0", + "@oxlint/binding-linux-x64-gnu": "1.56.0", + "@oxlint/binding-linux-x64-musl": "1.56.0", + "@oxlint/binding-openharmony-arm64": "1.56.0", + "@oxlint/binding-win32-arm64-msvc": "1.56.0", + "@oxlint/binding-win32-ia32-msvc": "1.56.0", + "@oxlint/binding-win32-x64-msvc": "1.56.0" + }, + "peerDependencies": { + "oxlint-tsgolint": ">=0.15.0" + }, + "peerDependenciesMeta": { + "oxlint-tsgolint": { + "optional": true + } + } + }, + "node_modules/oxlint-tsgolint": { + "version": "0.17.0", + "resolved": "https://registry.npmjs.org/oxlint-tsgolint/-/oxlint-tsgolint-0.17.0.tgz", + "integrity": "sha512-TdrKhDZCgEYqONFo/j+KvGan7/k3tP5Ouz88wCqpOvJtI2QmcLfGsm1fcMvDnTik48Jj6z83IJBqlkmK9DnY1A==", + "dev": true, + "license": "MIT", + "bin": { + "tsgolint": "bin/tsgolint.js" + }, + "optionalDependencies": { + "@oxlint-tsgolint/darwin-arm64": "0.17.0", + "@oxlint-tsgolint/darwin-x64": "0.17.0", + "@oxlint-tsgolint/linux-arm64": "0.17.0", + "@oxlint-tsgolint/linux-x64": "0.17.0", + "@oxlint-tsgolint/win32-arm64": "0.17.0", + "@oxlint-tsgolint/win32-x64": "0.17.0" + } + }, "node_modules/p-limit": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", @@ -4259,9 +4731,9 @@ } }, "node_modules/tar": { - "version": "7.5.9", - "resolved": "https://registry.npmjs.org/tar/-/tar-7.5.9.tgz", - "integrity": "sha512-BTLcK0xsDh2+PUe9F6c2TlRp4zOOBMTkoQHQIWSIzI0R7KG46uEwq4OPk2W7bZcprBMsuaeFsqwYr7pjh6CuHg==", + "version": "7.5.11", + "resolved": "https://registry.npmjs.org/tar/-/tar-7.5.11.tgz", + "integrity": "sha512-ChjMH33/KetonMTAtpYdgUFr0tbz69Fp2v7zWxQfYZX4g5ZN2nOBXm1R2xyA+lMIKrLKIoKAwFj93jE/avX9cQ==", "dev": true, "license": "BlueOak-1.0.0", "dependencies": { diff --git a/package.json b/package.json index 27cdae83..a3ae84bb 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,10 @@ "postversion": "npm publish", "prepublishOnly": "git push origin --follow-tags", "format": "prettier --write . --log-level warn", - "typedoc": "typedoc --tsconfig .tshy/esm.json ./src/*.ts" + "typedoc": "typedoc --tsconfig .tshy/esm.json ./src/*.ts", + "lint": "oxlint --fix src test", + "postsnap": "npm run lint", + "postlint": "npm run format" }, "dependencies": { "@isaacs/fs-minipass": "^4.0.0", @@ -28,13 +31,15 @@ "yallist": "^5.0.0" }, "devDependencies": { - "@types/node": "^25.3.3", + "@types/node": "^25.5.0", "chmodr": "^2.0.2", "end-of-stream": "^1.4.3", - "esbuild": "^0.27.3", + "esbuild": "^0.27.4", "events-to-array": "^2.0.3", "mutate-fs": "^2.1.1", "nock": "^13.5.4", + "oxlint": "^1.56.0", + "oxlint-tsgolint": "^0.17.0", "prettier": "^3.8.1", "rimraf": "^6.1.2", "tap": "^21.6.2", diff --git a/scripts/generate-parse-fixtures.js b/scripts/generate-parse-fixtures.js index b81f5265..85709a0f 100644 --- a/scripts/generate-parse-fixtures.js +++ b/scripts/generate-parse-fixtures.js @@ -17,8 +17,7 @@ const makeTest = (tarfile, tardata, maxMeta, filter, strict) => { (filter ? '-filter' : '') + (strict ? '-strict' : '') const tail = (o ? '-' + o : '') + '.json' - const eventsfile = - parsedir + '/' + path.basename(tarfile, '.tar') + tail + const eventsfile = parsedir + '/' + path.basename(tarfile, '.tar') + tail const p = new Parser({ maxMetaEntrySize: maxMeta, diff --git a/src/create.ts b/src/create.ts index 13d79852..2053a1ec 100644 --- a/src/create.ts +++ b/src/create.ts @@ -1,9 +1,9 @@ import { WriteStream, WriteStreamSync } from '@isaacs/fs-minipass' -import { Minipass } from 'minipass' +import type { Minipass } from 'minipass' import path from 'node:path' import { list } from './list.js' import { makeCommand } from './make-command.js' -import { +import type { TarOptions, TarOptionsFile, TarOptionsSync, @@ -54,12 +54,8 @@ const addFilesSync = (p: PackSync, files: string[]) => { p.end() } -const addFilesAsync = async ( - p: Pack, - files: string[], -): Promise => { - for (let i = 0; i < files.length; i++) { - const file = String(files[i]) +const addFilesAsync = async (p: Pack, files: string[]): Promise => { + for (const file of files) { if (file.charAt(0) === '@') { await list({ file: path.resolve(String(p.cwd), file.slice(1)), diff --git a/src/cwd-error.ts b/src/cwd-error.ts index bdc48046..9b176025 100644 --- a/src/cwd-error.ts +++ b/src/cwd-error.ts @@ -1,7 +1,7 @@ export class CwdError extends Error { path: string code: string - syscall: 'chdir' = 'chdir' + syscall = 'chdir' as const constructor(path: string, code: string) { super(`${code}: Cannot cd into '${path}'`) diff --git a/src/extract.ts b/src/extract.ts index 85a5bcdf..57d46417 100644 --- a/src/extract.ts +++ b/src/extract.ts @@ -3,7 +3,7 @@ import * as fsm from '@isaacs/fs-minipass' import fs from 'node:fs' import { filesFilter } from './list.js' import { makeCommand } from './make-command.js' -import { TarOptionsFile, TarOptionsSyncFile } from './options.js' +import type { TarOptionsFile, TarOptionsSyncFile } from './options.js' import { Unpack, UnpackSync } from './unpack.js' const extractFileSync = (opt: TarOptionsSyncFile) => { diff --git a/src/header.ts b/src/header.ts index 1c12dde6..6ec7787f 100644 --- a/src/header.ts +++ b/src/header.ts @@ -72,12 +72,7 @@ export class Header implements HeaderData { } } - decode( - buf: Buffer, - off: number, - ex?: HeaderData, - gex?: HeaderData, - ) { + decode(buf: Buffer, off: number, ex?: HeaderData, gex?: HeaderData) { if (!off) { off = 0 } @@ -91,8 +86,7 @@ export class Header implements HeaderData { this.uid = ex?.uid ?? gex?.uid ?? decNumber(buf, off + 108, 8) this.gid = ex?.gid ?? gex?.gid ?? decNumber(buf, off + 116, 8) this.size = ex?.size ?? gex?.size ?? decNumber(buf, off + 124, 12) - this.mtime = - ex?.mtime ?? gex?.mtime ?? decDate(buf, off + 136, 12) + this.mtime = ex?.mtime ?? gex?.mtime ?? decDate(buf, off + 136, 12) this.cksum = decNumber(buf, off + 148, 12) // if we have extended or global extended headers, apply them now @@ -121,14 +115,11 @@ export class Header implements HeaderData { this.linkpath = decString(buf, off + 157, 100) if ( - buf.subarray(off + 257, off + 265).toString() === - 'ustar\u000000' + buf.subarray(off + 257, off + 265).toString() === 'ustar\u000000' ) { /* c8 ignore start */ - this.uname = - ex?.uname ?? gex?.uname ?? decString(buf, off + 265, 32) - this.gname = - ex?.gname ?? gex?.gname ?? decString(buf, off + 297, 32) + this.uname = ex?.uname ?? gex?.uname ?? decString(buf, off + 265, 32) + this.gname = ex?.gname ?? gex?.gname ?? decString(buf, off + 297, 32) this.devmaj = ex?.devmaj ?? gex?.devmaj ?? decNumber(buf, off + 329, 8) ?? 0 this.devmin = @@ -144,10 +135,8 @@ export class Header implements HeaderData { this.path = prefix + '/' + this.path } /* c8 ignore start */ - this.atime = - ex?.atime ?? gex?.atime ?? decDate(buf, off + 476, 12) - this.ctime = - ex?.ctime ?? gex?.ctime ?? decDate(buf, off + 488, 12) + this.atime = ex?.atime ?? gex?.atime ?? decDate(buf, off + 476, 12) + this.ctime = ex?.ctime ?? gex?.ctime ?? decDate(buf, off + 488, 12) /* c8 ignore stop */ } } @@ -207,17 +196,12 @@ export class Header implements HeaderData { this.needPax = !!split[2] this.needPax = encString(buf, off, 100, path) || this.needPax - this.needPax = - encNumber(buf, off + 100, 8, this.mode) || this.needPax - this.needPax = - encNumber(buf, off + 108, 8, this.uid) || this.needPax - this.needPax = - encNumber(buf, off + 116, 8, this.gid) || this.needPax - this.needPax = - encNumber(buf, off + 124, 12, this.size) || this.needPax - this.needPax = - encDate(buf, off + 136, 12, this.mtime) || this.needPax - buf[off + 156] = this.#type.charCodeAt(0) + this.needPax = encNumber(buf, off + 100, 8, this.mode) || this.needPax + this.needPax = encNumber(buf, off + 108, 8, this.uid) || this.needPax + this.needPax = encNumber(buf, off + 116, 8, this.gid) || this.needPax + this.needPax = encNumber(buf, off + 124, 12, this.size) || this.needPax + this.needPax = encDate(buf, off + 136, 12, this.mtime) || this.needPax + buf[off + 156] = Number(this.#type.codePointAt(0)) this.needPax = encString(buf, off + 157, 100, this.linkpath) || this.needPax buf.write('ustar\u000000', off + 257, 8) @@ -232,11 +216,9 @@ export class Header implements HeaderData { this.needPax = encString(buf, off + 345, prefixSize, prefix) || this.needPax if (buf[off + 475] !== 0) { - this.needPax = - encString(buf, off + 345, 155, prefix) || this.needPax + this.needPax = encString(buf, off + 345, 155, prefix) || this.needPax } else { - this.needPax = - encString(buf, off + 345, 130, prefix) || this.needPax + this.needPax = encString(buf, off + 345, 130, prefix) || this.needPax this.needPax = encDate(buf, off + 476, 12, this.atime) || this.needPax this.needPax = @@ -390,12 +372,7 @@ const padOctal = (str: string, size: number) => str : new Array(size - str.length - 1).join('0') + str + ' ') + '\0' -const encDate = ( - buf: Buffer, - off: number, - size: 8 | 12, - date?: Date, -) => +const encDate = (buf: Buffer, off: number, size: 8 | 12, date?: Date) => date === undefined ? false : ( encNumber(buf, off, size, date.getTime() / 1000) ) diff --git a/src/large-numbers.ts b/src/large-numbers.ts index cc015315..9af2bfab 100644 --- a/src/large-numbers.ts +++ b/src/large-numbers.ts @@ -56,9 +56,7 @@ export const parse = (buf: Buffer) => { if (!Number.isSafeInteger(value)) { // The number is so large that javascript cannot represent it with integer // precision. - throw Error( - 'parsed number outside of javascript safe integer range', - ) + throw Error('parsed number outside of javascript safe integer range') } return value diff --git a/src/list.ts b/src/list.ts index ac9ed819..8e236bf2 100644 --- a/src/list.ts +++ b/src/list.ts @@ -3,7 +3,7 @@ import * as fsm from '@isaacs/fs-minipass' import fs from 'node:fs' import { dirname, parse } from 'path' import { makeCommand } from './make-command.js' -import { +import type { TarOptions, TarOptionsFile, TarOptionsSyncFile, @@ -36,11 +36,7 @@ export const filesFilter = (opt: TarOptions, files: string[]) => { if (file === root) ret = false else { const m = map.get(file) - if (m !== undefined) { - ret = m - } else { - ret = mapHas(dirname(file), root) - } + ret = m !== undefined ? m : mapHas(dirname(file), root) } map.set(file, ret) @@ -82,7 +78,7 @@ const listFileSync = (opt: TarOptionsSyncFile) => { try { fs.closeSync(fd) /* c8 ignore next */ - } catch (er) {} + } catch {} } } } diff --git a/src/make-command.ts b/src/make-command.ts index 7a0e8b2e..5eee45dc 100644 --- a/src/make-command.ts +++ b/src/make-command.ts @@ -1,9 +1,4 @@ -import { - dealias, - isAsyncFile, - isAsyncNoFile, - isSyncFile, - isSyncNoFile, +import type { TarOptions, TarOptionsAsyncFile, TarOptionsAsyncNoFile, @@ -19,21 +14,22 @@ import { TarOptionsWithAliasesSyncFile, TarOptionsWithAliasesSyncNoFile, } from './options.js' +import { + dealias, + isAsyncFile, + isAsyncNoFile, + isSyncFile, + isSyncNoFile, +} from './options.js' -export type CB = (er?: Error) => any +export type CB = (er?: Error) => unknown -export type TarCommand< - AsyncClass, - SyncClass extends { sync: true }, -> = { +export type TarCommand = { // async and no file specified (): AsyncClass (opt: TarOptionsWithAliasesAsyncNoFile): AsyncClass (entries: string[]): AsyncClass - ( - opt: TarOptionsWithAliasesAsyncNoFile, - entries: string[], - ): AsyncClass + (opt: TarOptionsWithAliasesAsyncNoFile, entries: string[]): AsyncClass } & { // sync and no file (opt: TarOptionsWithAliasesSyncNoFile): SyncClass @@ -41,10 +37,7 @@ export type TarCommand< } & { // async and file (opt: TarOptionsWithAliasesAsyncFile): Promise - ( - opt: TarOptionsWithAliasesAsyncFile, - entries: string[], - ): Promise + (opt: TarOptionsWithAliasesAsyncFile, entries: string[]): Promise (opt: TarOptionsWithAliasesAsyncFile, cb: CB): Promise ( opt: TarOptionsWithAliasesAsyncFile, @@ -146,10 +139,7 @@ export type TarCommand< entries: string[], cb?: CB, ) => Promise - syncNoFile: ( - opt: TarOptionsSyncNoFile, - entries: string[], - ) => SyncClass + syncNoFile: (opt: TarOptionsSyncNoFile, entries: string[]) => SyncClass asyncNoFile: ( opt: TarOptionsAsyncNoFile, entries: string[], @@ -157,20 +147,14 @@ export type TarCommand< validate?: (opt: TarOptions, entries?: string[]) => void } -export const makeCommand = < - AsyncClass, - SyncClass extends { sync: true }, ->( +export const makeCommand = ( syncFile: (opt: TarOptionsSyncFile, entries: string[]) => void, asyncFile: ( opt: TarOptionsAsyncFile, entries: string[], cb?: CB, ) => Promise, - syncNoFile: ( - opt: TarOptionsSyncNoFile, - entries: string[], - ) => SyncClass, + syncNoFile: (opt: TarOptionsSyncNoFile, entries: string[]) => SyncClass, asyncNoFile: ( opt: TarOptionsAsyncNoFile, entries: string[], @@ -193,11 +177,7 @@ export const makeCommand = < entries = undefined } - if (!entries) { - entries = [] - } else { - entries = Array.from(entries) - } + entries = !entries ? [] : Array.from(entries) const opt = dealias(opt_) @@ -212,9 +192,7 @@ export const makeCommand = < return syncFile(opt, entries) } else if (isAsyncFile(opt)) { const p = asyncFile(opt, entries) - // weirdness to make TS happy - const c = cb ? cb : undefined - return c ? p.then(() => c(), c) : p + return cb ? p.then(() => cb(), cb) : p } else if (isSyncNoFile(opt)) { if (typeof cb === 'function') { throw new TypeError( @@ -224,15 +202,13 @@ export const makeCommand = < return syncNoFile(opt, entries) } else if (isAsyncNoFile(opt)) { if (typeof cb === 'function') { - throw new TypeError( - 'callback only supported with file option', - ) + throw new TypeError('callback only supported with file option') } return asyncNoFile(opt, entries) /* c8 ignore start */ - } else { - throw new Error('impossible options??') } + throw new Error('impossible options??') + /* c8 ignore stop */ }, { diff --git a/src/mkdir.ts b/src/mkdir.ts index 7fce7769..3ab66dac 100644 --- a/src/mkdir.ts +++ b/src/mkdir.ts @@ -18,14 +18,11 @@ export type MkdirOptions = { mode: number } -export type MkdirError = - | NodeJS.ErrnoException - | CwdError - | SymlinkError +export type MkdirError = NodeJS.ErrnoException | CwdError | SymlinkError const checkCwd = ( dir: string, - cb: (er?: null | MkdirError) => any, + cb: (er?: null | MkdirError) => unknown, ) => { fs.stat(dir, (er, st) => { if (er || !st.isDirectory()) { @@ -76,9 +73,7 @@ export const mkdir = ( cb(er) } else { if (created && doChown) { - chownr(created, uid, gid, er => - done(er as NodeJS.ErrnoException), - ) + chownr(created, uid, gid, er => done(er as NodeJS.ErrnoException)) } else if (needChmod) { fs.chmod(dir, mode, cb) } else { @@ -112,7 +107,7 @@ const mkdir_ = ( created: string | undefined, cb: (er?: null | MkdirError, made?: string) => void, ): void => { - if (!parts.length) { + if (parts.length === 0) { return cb(null, created) } const p = parts.shift() @@ -138,8 +133,7 @@ const onmkdir = if (er) { fs.lstat(part, (statEr, st) => { if (statEr) { - statEr.path = - statEr.path && normalizeWindowsPath(statEr.path) + statEr.path = statEr.path && normalizeWindowsPath(statEr.path) cb(statEr) } else if (st.isDirectory()) { mkdir_(part, parts, mode, unlink, cwd, created, cb) @@ -155,9 +149,7 @@ const onmkdir = ) }) } else if (st.isSymbolicLink()) { - return cb( - new SymlinkError(part, part + '/' + parts.join('/')), - ) + return cb(new SymlinkError(part, part + '/' + parts.join('/'))) } else { cb(er) } @@ -170,7 +162,7 @@ const onmkdir = const checkCwdSync = (dir: string) => { let ok = false - let code: string | undefined = undefined + let code try { ok = fs.statSync(dir).isDirectory() } catch (er) { @@ -217,14 +209,12 @@ export const mkdirSync = (dir: string, opt: MkdirOptions) => { } if (preserve) { - return done( - fs.mkdirSync(dir, { mode, recursive: true }) ?? undefined, - ) + return done(fs.mkdirSync(dir, { mode, recursive: true }) ?? undefined) } const sub = normalizeWindowsPath(path.relative(cwd, dir)) const parts = sub.split('/') - let created: string | undefined = undefined + let created for ( let p = parts.shift(), part = cwd; p && (part += '/' + p); @@ -235,7 +225,7 @@ export const mkdirSync = (dir: string, opt: MkdirOptions) => { try { fs.mkdirSync(part, mode) created = created || part - } catch (er) { + } catch { const st = fs.lstatSync(part) if (st.isDirectory()) { continue diff --git a/src/normalize-windows-path.ts b/src/normalize-windows-path.ts index 7655119a..af5742a8 100644 --- a/src/normalize-windows-path.ts +++ b/src/normalize-windows-path.ts @@ -3,10 +3,9 @@ // so, on windows, and only on windows, we replace all \ chars with /, // so that we can use / as our one and only directory separator char. -const platform = - process.env.TESTING_TAR_FAKE_PLATFORM || process.platform +const platform = process.env.TESTING_TAR_FAKE_PLATFORM || process.platform export const normalizeWindowsPath = platform !== 'win32' ? (p: string) => p - : (p: string) => p && p.replace(/\\/g, '/') + : (p: string) => p && p.replaceAll(/\\/g, '/') diff --git a/src/options.ts b/src/options.ts index 566d4c80..7971eeab 100644 --- a/src/options.ts +++ b/src/options.ts @@ -4,32 +4,30 @@ import { type GzipOptions, type ZlibOptions } from 'minizlib' import { type Stats } from 'node:fs' import { type ReadEntry } from './read-entry.js' import { type WarnData } from './warn-method.js' -import { WriteEntry } from './write-entry.js' - -const argmap = new Map( - [ - ['C', 'cwd'], - ['f', 'file'], - ['z', 'gzip'], - ['P', 'preservePaths'], - ['U', 'unlink'], - ['strip-components', 'strip'], - ['stripComponents', 'strip'], - ['keep-newer', 'newer'], - ['keepNewer', 'newer'], - ['keep-newer-files', 'newer'], - ['keepNewerFiles', 'newer'], - ['k', 'keep'], - ['keep-existing', 'keep'], - ['keepExisting', 'keep'], - ['m', 'noMtime'], - ['no-mtime', 'noMtime'], - ['p', 'preserveOwner'], - ['L', 'follow'], - ['h', 'follow'], - ['onentry', 'onReadEntry'], - ], -) +import type { WriteEntry } from './write-entry.js' + +const argmap = new Map([ + ['C', 'cwd'], + ['f', 'file'], + ['z', 'gzip'], + ['P', 'preservePaths'], + ['U', 'unlink'], + ['strip-components', 'strip'], + ['stripComponents', 'strip'], + ['keep-newer', 'newer'], + ['keepNewer', 'newer'], + ['keep-newer-files', 'newer'], + ['keepNewerFiles', 'newer'], + ['k', 'keep'], + ['keep-existing', 'keep'], + ['keepExisting', 'keep'], + ['m', 'noMtime'], + ['no-mtime', 'noMtime'], + ['p', 'preserveOwner'], + ['L', 'follow'], + ['h', 'follow'], + ['onentry', 'onReadEntry'], +]) /** * The options that can be provided to tar commands. @@ -153,7 +151,7 @@ export interface TarOptions { * Note: if `strict` is set, then the warning will throw, and this method * will not be called. */ - onwarn?: (code: string, message: string, data: WarnData) => any + onwarn?: (code: string, message: string, data: WarnData) => unknown ////////////////////////// // extraction options @@ -239,7 +237,7 @@ export interface TarOptions { * [MiniPass](http://npm.im/minipass)-based streams are designed for this use * case. */ - transform?: (entry: ReadEntry) => any + transform?: (entry: ReadEntry) => ReadEntry /** * Call `chmod()` to ensure that extracted files match the entry's mode @@ -298,7 +296,7 @@ export interface TarOptions { * When creating, updating, or replacing within archives, this method will * be called with each WriteEntry that is created. */ - onWriteEntry?: (entry: WriteEntry) => any + onWriteEntry?: (entry: WriteEntry) => unknown /** * When extracting or listing archives, this method will be called with @@ -307,7 +305,7 @@ export interface TarOptions { * Important when listing archives synchronously from a file, because there * is otherwise no way to interact with the data! */ - onReadEntry?: (entry: ReadEntry) => any + onReadEntry?: (entry: ReadEntry) => unknown /** * Pack the targets of symbolic links rather than the link itself. @@ -497,7 +495,7 @@ export interface TarOptions { * * @deprecated */ - onentry?: (entry: ReadEntry) => any + onentry?: (entry: ReadEntry) => unknown } export type TarOptionsSync = TarOptions & { sync: true } @@ -659,20 +657,20 @@ export type TarOptionsWithAliasesFile = file: string }) | (TarOptionsWithAliases & { f: string }) -export type TarOptionsWithAliasesSyncFile = - TarOptionsWithAliasesSync & TarOptionsWithAliasesFile -export type TarOptionsWithAliasesAsyncFile = - TarOptionsWithAliasesAsync & TarOptionsWithAliasesFile +export type TarOptionsWithAliasesSyncFile = TarOptionsWithAliasesSync & + TarOptionsWithAliasesFile +export type TarOptionsWithAliasesAsyncFile = TarOptionsWithAliasesAsync & + TarOptionsWithAliasesFile export type TarOptionsWithAliasesNoFile = TarOptionsWithAliases & { f?: undefined file?: undefined } -export type TarOptionsWithAliasesSyncNoFile = - TarOptionsWithAliasesSync & TarOptionsWithAliasesNoFile -export type TarOptionsWithAliasesAsyncNoFile = - TarOptionsWithAliasesAsync & TarOptionsWithAliasesNoFile +export type TarOptionsWithAliasesSyncNoFile = TarOptionsWithAliasesSync & + TarOptionsWithAliasesNoFile +export type TarOptionsWithAliasesAsyncNoFile = TarOptionsWithAliasesAsync & + TarOptionsWithAliasesNoFile export const isSyncFile = ( o: O, @@ -699,22 +697,18 @@ export const isNoFile = ( o: O, ): o is O & TarOptionsNoFile => !o.file -const dealiasKey = ( - k: keyof TarOptionsWithAliases, -): keyof TarOptions => { +const dealiasKey = (k: keyof TarOptionsWithAliases): keyof TarOptions => { const d = argmap.get(k) if (d) return d return k as keyof TarOptions } -export const dealias = ( - opt: TarOptionsWithAliases = {}, -): TarOptions => { +export const dealias = (opt: TarOptionsWithAliases = {}): TarOptions => { if (!opt) return {} - const result: Record = {} + const result: Record = {} for (const [key, v] of Object.entries(opt) as [ keyof TarOptionsWithAliases, - any, + unknown, ][]) { // TS doesn't know that aliases are going to always be the same type const k = dealiasKey(key) diff --git a/src/pack.ts b/src/pack.ts index fda7fd82..3b7996f4 100644 --- a/src/pack.ts +++ b/src/pack.ts @@ -33,12 +33,8 @@ import { Minipass } from 'minipass' import * as zlib from 'minizlib' import { Yallist } from 'yallist' import { ReadEntry } from './read-entry.js' -import { - WarnEvent, - warnMethod, - type WarnData, - type Warner, -} from './warn-method.js' +import type { WarnEvent } from './warn-method.js' +import { warnMethod, type WarnData, type Warner } from './warn-method.js' const EOF = Buffer.alloc(1024) const ONSTAT = Symbol('onStat') @@ -64,7 +60,7 @@ const ONDRAIN = Symbol('ondrain') import path from 'path' import { normalizeWindowsPath } from './normalize-windows-path.js' -import { TarOptions } from './options.js' +import type { TarOptions } from './options.js' export class Pack extends Minipass> @@ -107,7 +103,6 @@ export class Pack [ENDED]: boolean = false constructor(opt: TarOptions = {}) { - //@ts-ignore super() this.opt = opt this.file = opt.file || '' @@ -131,14 +126,10 @@ export class Pack if (opt.gzip || opt.brotli || opt.zstd) { if ( - (opt.gzip ? 1 : 0) + - (opt.brotli ? 1 : 0) + - (opt.zstd ? 1 : 0) > + (opt.gzip ? 1 : 0) + (opt.brotli ? 1 : 0) + (opt.zstd ? 1 : 0) > 1 ) { - throw new TypeError( - 'gzip, brotli, zstd are mutually exclusive', - ) + throw new TypeError('gzip, brotli, zstd are mutually exclusive') } if (opt.gzip) { if (typeof opt.gzip !== 'object') { @@ -242,9 +233,7 @@ export class Pack } [ADDTARENTRY](p: ReadEntry) { - const absolute = normalizeWindowsPath( - path.resolve(this.cwd, p.path), - ) + const absolute = normalizeWindowsPath(path.resolve(this.cwd, p.path)) // in this case, we don't have to wait for the stat if (!this.filter(p.path, p)) { p.resume() @@ -344,7 +333,7 @@ export class Pack this[PROCESSING] = false - if (this[ENDED] && !this[QUEUE].length && this[JOBS] === 0) { + if (this[ENDED] && this[QUEUE].length === 0 && this[JOBS] === 0) { if (this.zip) { this.zip.end(EOF) } else { @@ -393,11 +382,7 @@ export class Pack return } - if ( - !this.noDirRecurse && - job.stat.isDirectory() && - !job.readdir - ) { + if (!this.noDirRecurse && job.stat.isDirectory() && !job.readdir) { const rc = this.readdirCache.get(job.absolute) if (rc) { this[ONREADDIR](job, rc) @@ -443,10 +428,7 @@ export class Pack [ENTRY](job: PackJob) { this[JOBS] += 1 try { - const e = new this[WRITEENTRYCLASS]( - job.path, - this[ENTRYOPT](job), - ) + const e = new this[WRITEENTRYCLASS](job.path, this[ENTRYOPT](job)) return e .on('end', () => this[JOBDONE](job)) .on('error', er => this.emit('error', er)) @@ -500,11 +482,7 @@ export class Pack } return super.pause() } - warn( - code: string, - message: string | Error, - data: WarnData = {}, - ): void { + warn(code: string, message: string | Error, data: WarnData = {}): void { warnMethod(this, code, message, data) } } diff --git a/src/parse.ts b/src/parse.ts index 5dc6ee2f..5c38c8c2 100644 --- a/src/parse.ts +++ b/src/parse.ts @@ -21,14 +21,10 @@ import { EventEmitter as EE } from 'events' import { BrotliDecompress, Unzip, ZstdDecompress } from 'minizlib' import { Header } from './header.js' -import { TarOptions } from './options.js' +import type { TarOptions } from './options.js' import { Pax } from './pax.js' import { ReadEntry } from './read-entry.js' -import { - warnMethod, - type WarnData, - type Warner, -} from './warn-method.js' +import { warnMethod, type WarnData, type Warner } from './warn-method.js' const maxMetaEntrySize = 1024 * 1024 const gzipHeader = Buffer.from([0x1f, 0x8b]) @@ -81,7 +77,7 @@ export class Parser extends EE implements Warner { writable: true = true readable: false = false; - [QUEUE]: (ReadEntry | [string | symbol, any, any])[] = []; + [QUEUE]: (ReadEntry | [string | symbol, unknown, unknown])[] = []; [BUFFER]?: Buffer; [READENTRY]?: ReadEntry; [WRITEENTRY]?: ReadEntry; @@ -106,10 +102,7 @@ export class Parser extends EE implements Warner { // these BADARCHIVE errors can't be detected early. listen on DONE. this.on(DONE, () => { - if ( - this[STATE] === 'begin' || - this[SAW_VALID_ENTRY] === false - ) { + if (this[STATE] === 'begin' || this[SAW_VALID_ENTRY] === false) { // either less than 1 block of data, or all entries were invalid. // Either way, probably not even a tarball. this.warn('TAR_BAD_ARCHIVE', 'Unrecognized archive format') @@ -163,11 +156,7 @@ export class Parser extends EE implements Warner { } } - warn( - code: string, - message: string | Error, - data: WarnData = {}, - ): void { + warn(code: string, message: string | Error, data: WarnData = {}): void { warnMethod(this, code, message, data) } @@ -250,8 +239,7 @@ export class Parser extends EE implements Warner { } } else { this[EX] = undefined - entry.ignore = - entry.ignore || !this.filter(entry.path, entry) + entry.ignore = entry.ignore || !this.filter(entry.path, entry) if (entry.ignore) { // probably valid, just not something we care about @@ -283,14 +271,14 @@ export class Parser extends EE implements Warner { queueMicrotask(() => this.emit('close')) } - [PROCESSENTRY](entry?: ReadEntry | [string | symbol, any, any]) { + [PROCESSENTRY](entry?: ReadEntry | [string | symbol, unknown, unknown]) { let go = true if (!entry) { this[READENTRY] = undefined go = false } else if (Array.isArray(entry)) { - const [ev, ...args]: [string | symbol, any, any] = entry + const [ev, ...args]: [string | symbol, unknown, unknown] = entry this.emit(ev, ...args) } else { this[READENTRY] = entry @@ -307,7 +295,7 @@ export class Parser extends EE implements Warner { [NEXTENTRY]() { do {} while (this[PROCESSENTRY](this[QUEUE].shift())) - if (!this[QUEUE].length) { + if (this[QUEUE].length === 0) { // At this point, there's nothing in the queue, but we may have an // entry which is being consumed (readEntry). // If we don't, then we definitely can handle more data. @@ -364,8 +352,8 @@ export class Parser extends EE implements Warner { return ret } - [EMIT](ev: string | symbol, data?: any, extra?: any) { - if (!this[QUEUE].length && !this[READENTRY]) { + [EMIT](ev: string | symbol, data?: unknown, extra?: unknown) { + if (this[QUEUE].length === 0 && !this[READENTRY]) { this.emit(ev, data, extra) } else { this[QUEUE].push([ev, data, extra]) @@ -424,8 +412,8 @@ export class Parser extends EE implements Warner { ): boolean write( chunk: Buffer | string, - encoding?: BufferEncoding | (() => any), - cb?: () => any, + encoding?: BufferEncoding | (() => unknown), + cb?: () => unknown, ): boolean { if (typeof encoding === 'function') { cb = encoding @@ -544,12 +532,12 @@ export class Parser extends EE implements Warner { // return false if there's a queue, or if the current entry isn't flowing const ret = - this[QUEUE].length ? false + this[QUEUE].length > 0 ? false : this[READENTRY] ? this[READENTRY].flowing : true // if we have no queue, then that means a clogged READENTRY - if (!ret && !this[QUEUE].length) { + if (!ret && this[QUEUE].length === 0) { this[READENTRY]?.once('drain', () => this.emit('drain')) } @@ -560,8 +548,7 @@ export class Parser extends EE implements Warner { [BUFFERCONCAT](c: Buffer) { if (c && !this[ABORTED]) { - this[BUFFER] = - this[BUFFER] ? Buffer.concat([this[BUFFER], c]) : c + this[BUFFER] = this[BUFFER] ? Buffer.concat([this[BUFFER], c]) : c } } @@ -630,11 +617,7 @@ export class Parser extends EE implements Warner { // the buffer. Advance the position and put any remainder in the buffer. let position = 0 const length = chunk.length - while ( - position + 512 <= length && - !this[ABORTED] && - !this[SAW_EOF] - ) { + while (position + 512 <= length && !this[ABORTED] && !this[SAW_EOF]) { switch (this[STATE]) { case 'begin': case 'header': @@ -659,14 +642,10 @@ export class Parser extends EE implements Warner { } if (position < length) { - if (this[BUFFER]) { - this[BUFFER] = Buffer.concat([ - chunk.subarray(position), - this[BUFFER], - ]) - } else { - this[BUFFER] = chunk.subarray(position) - } + this[BUFFER] = + this[BUFFER] ? + Buffer.concat([chunk.subarray(position), this[BUFFER]]) + : chunk.subarray(position) } } diff --git a/src/path-reservations.ts b/src/path-reservations.ts index e585630e..5c5e325c 100644 --- a/src/path-reservations.ts +++ b/src/path-reservations.ts @@ -10,8 +10,7 @@ import { join } from 'node:path' import { normalizeUnicode } from './normalize-unicode.js' import { stripTrailingSlashes } from './strip-trailing-slashes.js' -const platform = - process.env.TESTING_TAR_FAKE_PLATFORM || process.platform +const platform = process.env.TESTING_TAR_FAKE_PLATFORM || process.platform const isWindows = platform === 'win32' export type Reservation = { @@ -28,7 +27,7 @@ const getDirs = (path: string) => { .split('/') .slice(0, -1) .reduce((set: string[], path) => { - const s = set[set.length - 1] + const s = set.at(-1) if (s !== undefined) { path = join(s, path) } @@ -76,7 +75,7 @@ export class PathReservations { if (!q) { this.#queues.set(dir, [new Set([fn])]) } else { - const l = q[q.length - 1] + const l = q.at(-1) if (l instanceof Set) { l.add(fn) } else { diff --git a/src/pax.ts b/src/pax.ts index f72e85c8..f08fa8d3 100644 --- a/src/pax.ts +++ b/src/pax.ts @@ -1,5 +1,6 @@ import { basename } from 'node:path' -import { Header, HeaderData } from './header.js' +import type { HeaderData } from './header.js' +import { Header } from './header.js' export class Pax implements HeaderData { atime?: Date @@ -153,7 +154,7 @@ const parseKV = (str: string) => .split('\n') .reduce(parseKVLine, Object.create(null)) -const parseKVLine = (set: Record, line: string) => { +const parseKVLine = (set: Record, line: string) => { const n = parseInt(line, 10) // XXX Values with \n in them will fail this. diff --git a/src/read-entry.ts b/src/read-entry.ts index 0649bc99..c6ba45be 100644 --- a/src/read-entry.ts +++ b/src/read-entry.ts @@ -1,8 +1,8 @@ import { Minipass } from 'minipass' -import { Header } from './header.js' +import type { Header } from './header.js' import { normalizeWindowsPath } from './normalize-windows-path.js' -import { Pax } from './pax.js' -import { EntryTypeName } from './types.js' +import type { Pax } from './pax.js' +import type { EntryTypeName } from './types.js' export class ReadEntry extends Minipass { extended?: Pax @@ -97,9 +97,7 @@ export class ReadEntry extends Minipass { this.ctime = header.ctime /* c8 ignore start */ this.linkpath = - header.linkpath ? - normalizeWindowsPath(header.linkpath) - : undefined + header.linkpath ? normalizeWindowsPath(header.linkpath) : undefined /* c8 ignore stop */ this.uname = header.uname this.gname = header.gname @@ -144,11 +142,7 @@ export class ReadEntry extends Minipass { // we slurp in everything except for the path attribute in // a global extended header, because that's weird. Also, any // null/undefined values are ignored. - return !( - v === null || - v === undefined || - (k === 'path' && gex) - ) + return !(v === null || v === undefined || (k === 'path' && gex)) }), ), ) diff --git a/src/replace.ts b/src/replace.ts index 10f120c2..ba6d3d80 100644 --- a/src/replace.ts +++ b/src/replace.ts @@ -1,16 +1,13 @@ // tar -r import { WriteStream, WriteStreamSync } from '@isaacs/fs-minipass' -import { Minipass } from 'minipass' +import type { Minipass } from 'minipass' import fs from 'node:fs' import path from 'node:path' import { Header } from './header.js' import { list } from './list.js' import { makeCommand } from './make-command.js' -import { - isFile, - TarOptionsFile, - TarOptionsSyncFile, -} from './options.js' +import type { TarOptionsFile, TarOptionsSyncFile } from './options.js' +import { isFile } from './options.js' import { Pack, PackSync } from './pack.js' // starting at the head of the file, read a Header @@ -40,11 +37,7 @@ const replaceSync = (opt: TarOptionsSyncFile, files: string[]) => { const st = fs.fstatSync(fd) const headBuf = Buffer.alloc(512) - POSITION: for ( - position = 0; - position < st.size; - position += 512 - ) { + POSITION: for (position = 0; position < st.size; position += 512) { for (let bufPos = 0, bytes = 0; bufPos < 512; bufPos += bytes) { bytes = fs.readSync( fd, @@ -54,11 +47,7 @@ const replaceSync = (opt: TarOptionsSyncFile, files: string[]) => { position + bufPos, ) - if ( - position === 0 && - headBuf[0] === 0x1f && - headBuf[1] === 0x8b - ) { + if (position === 0 && headBuf[0] === 0x1f && headBuf[1] === 0x8b) { throw new Error('cannot append to compressed archives') } @@ -89,7 +78,7 @@ const replaceSync = (opt: TarOptionsSyncFile, files: string[]) => { if (threw) { try { fs.closeSync(fd as number) - } catch (er) {} + } catch {} } } } @@ -137,7 +126,7 @@ const replaceAsync = ( let bufPos = 0 const headBuf = Buffer.alloc(512) const onread = (er?: null | Error, bytes?: number): void => { - if (er || typeof bytes === 'undefined') { + if (er || bytes === undefined) { return cb(er) } bufPos += bytes @@ -152,11 +141,7 @@ const replaceAsync = ( ) } - if ( - position === 0 && - headBuf[0] === 0x1f && - headBuf[1] === 0x8b - ) { + if (position === 0 && headBuf[0] === 0x1f && headBuf[1] === 0x8b) { return cb(new Error('cannot append to compressed archives')) } @@ -193,10 +178,7 @@ const replaceAsync = ( const promise = new Promise((resolve, reject) => { p.on('error', reject) let flag = 'r+' - const onopen = ( - er?: NodeJS.ErrnoException | null, - fd?: number, - ) => { + const onopen = (er?: NodeJS.ErrnoException | null, fd?: number) => { if (er && er.code === 'ENOENT' && flag === 'r+') { flag = 'w+' return fs.open(opt.file, flag, onopen) @@ -248,12 +230,8 @@ const addFilesSync = (p: Pack, files: string[]) => { p.end() } -const addFilesAsync = async ( - p: Pack, - files: string[], -): Promise => { - for (let i = 0; i < files.length; i++) { - const file = String(files[i]) +const addFilesAsync = async (p: Pack, files: string[]): Promise => { + for (const file of files) { if (file.charAt(0) === '@') { await list({ file: path.resolve(String(p.cwd), file.slice(1)), diff --git a/src/symlink-error.ts b/src/symlink-error.ts index 13c4531d..2572a36b 100644 --- a/src/symlink-error.ts +++ b/src/symlink-error.ts @@ -1,8 +1,8 @@ export class SymlinkError extends Error { path: string symlink: string - syscall: 'symlink' = 'symlink' - code: 'TAR_SYMLINK_ERROR' = 'TAR_SYMLINK_ERROR' + syscall = 'symlink' as const + code = 'TAR_SYMLINK_ERROR' as const constructor(symlink: string, path: string) { super('TAR_SYMLINK_ERROR: Cannot extract through symbolic link') this.symlink = symlink diff --git a/src/unpack.ts b/src/unpack.ts index b34ef1d4..9322dab1 100644 --- a/src/unpack.ts +++ b/src/unpack.ts @@ -10,16 +10,17 @@ import { randomBytes } from 'node:crypto' import fs, { type Stats } from 'node:fs' import path from 'node:path' import { getWriteFlag } from './get-write-flag.js' -import { mkdir, MkdirError, mkdirSync } from './mkdir.js' +import type { MkdirError } from './mkdir.js' +import { mkdir, mkdirSync } from './mkdir.js' import { normalizeWindowsPath } from './normalize-windows-path.js' import { Parser } from './parse.js' import { stripAbsolutePath } from './strip-absolute-path.js' import * as wc from './winchars.js' -import { TarOptions } from './options.js' +import type { TarOptions } from './options.js' import { PathReservations } from './path-reservations.js' -import { ReadEntry } from './read-entry.js' -import { WarnData } from './warn-method.js' +import type { ReadEntry } from './read-entry.js' +import type { WarnData } from './warn-method.js' import { SymlinkError } from './symlink-error.js' import { umask } from './process-umask.js' @@ -49,8 +50,7 @@ const DOCHOWN = Symbol('doChown') const UID = Symbol('uid') const GID = Symbol('gid') const CHECKED_CWD = Symbol('checkedCwd') -const platform = - process.env.TESTING_TAR_FAKE_PLATFORM || process.platform +const platform = process.env.TESTING_TAR_FAKE_PLATFORM || process.platform const isWindows = platform === 'win32' const DEFAULT_MAX_DEPTH = 1024 @@ -70,10 +70,7 @@ const DEFAULT_MAX_DEPTH = 1024 // // See: https://github.com/npm/node-tar/issues/183 /* c8 ignore start */ -const unlinkFile = ( - path: string, - cb: (er?: Error | null) => void, -) => { +const unlinkFile = (path: string, cb: (er?: Error | null) => void) => { if (!isWindows) { return fs.unlink(path, cb) } @@ -155,13 +152,8 @@ export class Unpack extends Parser { if (typeof opt.uid === 'number' || typeof opt.gid === 'number') { // need both or neither - if ( - typeof opt.uid !== 'number' || - typeof opt.gid !== 'number' - ) { - throw new TypeError( - 'cannot set owner without number uid and gid', - ) + if (typeof opt.uid !== 'number' || typeof opt.gid !== 'number') { + throw new TypeError('cannot set owner without number uid and gid') } if (opt.preserveOwner) { throw new TypeError( @@ -178,16 +170,10 @@ export class Unpack extends Parser { } // default true for root - if ( - opt.preserveOwner === undefined && - typeof opt.uid !== 'number' - ) { - this.preserveOwner = !!( - process.getuid && process.getuid() === 0 - ) - } else { - this.preserveOwner = !!opt.preserveOwner - } + this.preserveOwner = + opt.preserveOwner === undefined && typeof opt.uid !== 'number' ? + !!(process.getuid && process.getuid() === 0) + : !!opt.preserveOwner this.processUid = (this.preserveOwner || this.setOwner) && process.getuid ? @@ -201,9 +187,7 @@ export class Unpack extends Parser { // prevent excessively deep nesting of subfolders // set to `Infinity` to remove this restriction this.maxDepth = - typeof opt.maxDepth === 'number' ? - opt.maxDepth - : DEFAULT_MAX_DEPTH + typeof opt.maxDepth === 'number' ? opt.maxDepth : DEFAULT_MAX_DEPTH // mostly just for testing, but useful in some cases. // Forcibly trigger a chown on every entry, no matter what @@ -230,9 +214,7 @@ export class Unpack extends Parser { // links, and removes symlink directories rather than erroring this.unlink = !!opt.unlink - this.cwd = normalizeWindowsPath( - path.resolve(opt.cwd || process.cwd()), - ) + this.cwd = normalizeWindowsPath(path.resolve(opt.cwd || process.cwd())) this.strip = Number(opt.strip) || 0 // if we're not chmodding, then we don't need the process umask this.processUmask = @@ -279,7 +261,7 @@ export class Unpack extends Parser { // strip off the root const [root, stripped] = stripAbsolutePath(p) - const parts = stripped.replace(/\\/g, '/').split('/') + const parts = stripped.replaceAll(/\\/g, '/').split('/') if ( parts.includes('..') || @@ -297,26 +279,25 @@ export class Unpack extends Parser { }) // not ok! return false - } else { - // Resolve linkpath relative to the entry's directory. - // `path.posix` is safe to use because we're operating on - // tar paths, not a filesystem. - const entryDir = path.posix.dirname(entry.path) - const resolved = path.posix.normalize( - path.posix.join(entryDir, parts.join('/')), + } + // Resolve linkpath relative to the entry's directory. + // `path.posix` is safe to use because we're operating on + // tar paths, not a filesystem. + const entryDir = path.posix.dirname(entry.path) + const resolved = path.posix.normalize( + path.posix.join(entryDir, parts.join('/')), + ) + // If the resolved path escapes (starts with ..), reject it + if (resolved.startsWith('../') || resolved === '..') { + this.warn( + 'TAR_ENTRY_ERROR', + `${field} escapes extraction directory`, + { + entry, + [field]: p, + }, ) - // If the resolved path escapes (starts with ..), reject it - if (resolved.startsWith('../') || resolved === '..') { - this.warn( - 'TAR_ENTRY_ERROR', - `${field} escapes extraction directory`, - { - entry, - [field]: p, - }, - ) - return false - } + return false } } @@ -375,13 +356,10 @@ export class Unpack extends Parser { return false } - if (path.isAbsolute(entry.path)) { - entry.absolute = normalizeWindowsPath(path.resolve(entry.path)) - } else { - entry.absolute = normalizeWindowsPath( - path.resolve(this.cwd, entry.path), - ) - } + entry.absolute = + path.isAbsolute(entry.path) ? + normalizeWindowsPath(path.resolve(entry.path)) + : normalizeWindowsPath(path.resolve(this.cwd, entry.path)) // if we somehow ended up with a path that escapes the cwd, and we are // not in preservePaths mode, then something is fishy! This should have @@ -500,8 +478,7 @@ export class Unpack extends Parser { entry.uid !== this.processUid) || (typeof entry.gid === 'number' && entry.gid !== this.processGid))) || - (typeof this.uid === 'number' && - this.uid !== this.processUid) || + (typeof this.uid === 'number' && this.uid !== this.processUid) || (typeof this.gid === 'number' && this.gid !== this.processGid) ) } @@ -516,9 +493,7 @@ export class Unpack extends Parser { [FILE](entry: ReadEntry, fullyDone: () => void) { const mode = - typeof entry.mode === 'number' ? - entry.mode & 0o7777 - : this.fmode + typeof entry.mode === 'number' ? entry.mode & 0o7777 : this.fmode const stream = new fsm.WriteStream(String(entry.absolute), { // slight lie, but it can be numeric flags flags: getWriteFlag(entry.size) as string, @@ -590,9 +565,7 @@ export class Unpack extends Parser { const gid = this[GID](entry) if (typeof uid === 'number' && typeof gid === 'number') { fs.fchown(fd, uid, gid, er => - er ? - fs.chown(abs, uid, gid, er2 => done(er2 && er)) - : done(), + er ? fs.chown(abs, uid, gid, er2 => done(er2 && er)) : done(), ) } } @@ -602,8 +575,8 @@ export class Unpack extends Parser { const tx = this.transform ? this.transform(entry) || entry : entry if (tx !== entry) { - tx.on('error', (er: Error) => { - this[ONERROR](er, entry) + tx.on('error', er => { + this[ONERROR](er as Error, entry) fullyDone() }) entry.pipe(tx) @@ -613,9 +586,7 @@ export class Unpack extends Parser { [DIRECTORY](entry: ReadEntry, fullyDone: () => void) { const mode = - typeof entry.mode === 'number' ? - entry.mode & 0o7777 - : this.dmode + typeof entry.mode === 'number' ? entry.mode & 0o7777 : this.dmode this[MKDIR](String(entry.absolute), mode, er => { if (er) { this[ONERROR](er, entry) @@ -680,8 +651,7 @@ export class Unpack extends Parser { entry, this.cwd, parts, - () => - this[LINK](entry, String(entry.linkpath), 'symlink', done), + () => this[LINK](entry, String(entry.linkpath), 'symlink', done), er => { this[ONERROR](er, entry) done() @@ -693,9 +663,7 @@ export class Unpack extends Parser { const linkpath = normalizeWindowsPath( path.resolve(this.cwd, String(entry.linkpath)), ) - const parts = normalizeWindowsPath(String(entry.linkpath)).split( - '/', - ) + const parts = normalizeWindowsPath(String(entry.linkpath)).split('/') this[ENSURE_NO_SYMLINK]( entry, this.cwd, @@ -763,9 +731,7 @@ export class Unpack extends Parser { if (entry.linkpath) { paths.push(entry.linkpath) } - this.reservations.reserve(paths, done => - this[CHECKFS2](entry, done), - ) + this.reservations.reserve(paths, done => this[CHECKFS2](entry, done)) } [CHECKFS2](entry: ReadEntry, fullyDone: (er?: Error) => void) { @@ -823,9 +789,7 @@ export class Unpack extends Parser { if (st.isDirectory()) { if (entry.type === 'Directory') { const needChmod = - this.chmod && - entry.mode && - (st.mode & 0o7777) !== entry.mode + this.chmod && entry.mode && (st.mode & 0o7777) !== entry.mode const afterChmod = (er?: Error | null | undefined) => this[MAKEFS](er ?? null, entry, done) if (!needChmod) { @@ -845,10 +809,8 @@ export class Unpack extends Parser { // In that case, the user has opted out of path protections // explicitly, so if they blow away the cwd, c'est la vie. if (entry.absolute !== this.cwd) { - return fs.rmdir( - String(entry.absolute), - (er?: null | Error) => - this[MAKEFS](er ?? null, entry, done), + return fs.rmdir(String(entry.absolute), (er?: null | Error) => + this[MAKEFS](er ?? null, entry, done), ) } } @@ -978,9 +940,7 @@ export class UnpackSync extends Unpack { if (st.isDirectory()) { if (entry.type === 'Directory') { const needChmod = - this.chmod && - entry.mode && - (st.mode & 0o7777) !== entry.mode + this.chmod && entry.mode && (st.mode & 0o7777) !== entry.mode const [er] = needChmod ? callSync(() => { @@ -990,9 +950,7 @@ export class UnpackSync extends Unpack { return this[MAKEFS](er, entry) } // not a dir entry, have to remove it - const [er] = callSync(() => - fs.rmdirSync(String(entry.absolute)), - ) + const [er] = callSync(() => fs.rmdirSync(String(entry.absolute))) this[MAKEFS](er, entry) } @@ -1007,9 +965,7 @@ export class UnpackSync extends Unpack { [FILE](entry: ReadEntry, done: () => void) { const mode = - typeof entry.mode === 'number' ? - entry.mode & 0o7777 - : this.fmode + typeof entry.mode === 'number' ? entry.mode & 0o7777 : this.fmode const oner = (er?: null | Error | undefined) => { let closeError @@ -1041,7 +997,7 @@ export class UnpackSync extends Unpack { /* c8 ignore stop */ const tx = this.transform ? this.transform(entry) || entry : entry if (tx !== entry) { - tx.on('error', (er: Error) => this[ONERROR](er, entry)) + tx.on('error', er => this[ONERROR](er as Error, entry)) entry.pipe(tx) } @@ -1065,7 +1021,7 @@ export class UnpackSync extends Unpack { } catch (futimeser) { try { fs.utimesSync(String(entry.absolute), atime, mtime) - } catch (utimeser) { + } catch { er = futimeser } } @@ -1079,12 +1035,8 @@ export class UnpackSync extends Unpack { fs.fchownSync(fd, Number(uid), Number(gid)) } catch (fchowner) { try { - fs.chownSync( - String(entry.absolute), - Number(uid), - Number(gid), - ) - } catch (chowner) { + fs.chownSync(String(entry.absolute), Number(uid), Number(gid)) + } catch { er = er || fchowner } } @@ -1096,9 +1048,7 @@ export class UnpackSync extends Unpack { [DIRECTORY](entry: ReadEntry, done: () => void) { const mode = - typeof entry.mode === 'number' ? - entry.mode & 0o7777 - : this.dmode + typeof entry.mode === 'number' ? entry.mode & 0o7777 : this.dmode const er = this[MKDIR](String(entry.absolute), mode) if (er) { this[ONERROR](er as Error, entry) @@ -1113,7 +1063,7 @@ export class UnpackSync extends Unpack { entry.mtime, ) /* c8 ignore next */ - } catch (er) {} + } catch {} } if (this[DOCHOWN](entry)) { try { @@ -1122,7 +1072,7 @@ export class UnpackSync extends Unpack { Number(this[UID](entry)), Number(this[GID](entry)), ) - } catch (er) {} + } catch {} } done() entry.resume() @@ -1153,7 +1103,7 @@ export class UnpackSync extends Unpack { done: () => void, onError: (er: SymlinkError) => void, ) { - if (this.preservePaths || !parts.length) return done() + if (this.preservePaths || parts.length === 0) return done() let t = cwd for (const p of parts) { t = path.resolve(t, p) diff --git a/src/warn-method.ts b/src/warn-method.ts index 65ca99f0..ae08331f 100644 --- a/src/warn-method.ts +++ b/src/warn-method.ts @@ -2,17 +2,12 @@ import { type Minipass } from 'minipass' /** has a warn method */ export type Warner = { - warn(code: string, message: string | Error, data: any): void + warn(code: string, message: string | Error, data: unknown): void file?: string cwd?: string strict?: boolean - emit( - event: 'warn', - code: string, - message: string, - data?: WarnData, - ): void + emit(event: 'warn', code: string, message: string, data?: WarnData): void emit(event: 'error', error: TarError): void } @@ -26,7 +21,7 @@ export type WarnData = { code?: string tarCode?: string recoverable?: boolean - [k: string]: any + [k: string]: unknown } export type TarError = Error & WarnData diff --git a/src/winchars.ts b/src/winchars.ts index b8edeb36..83941b1b 100644 --- a/src/winchars.ts +++ b/src/winchars.ts @@ -4,7 +4,7 @@ const raw = ['|', '<', '>', '?', ':'] const win = raw.map(char => - String.fromCharCode(0xf000 + char.charCodeAt(0)), + String.fromCodePoint(0xf000 + Number(char.codePointAt(0))), ) const toWin = new Map(raw.map((char, i) => [char, win[i]])) diff --git a/src/write-entry.ts b/src/write-entry.ts index fabead4d..36fa276e 100644 --- a/src/write-entry.ts +++ b/src/write-entry.ts @@ -4,23 +4,19 @@ import path from 'path' import { Header } from './header.js' import { modeFix } from './mode-fix.js' import { normalizeWindowsPath } from './normalize-windows-path.js' -import { - dealias, +import type { LinkCacheKey, TarOptions, TarOptionsWithAliases, } from './options.js' +import { dealias } from './options.js' import { Pax } from './pax.js' -import { ReadEntry } from './read-entry.js' +import type { ReadEntry } from './read-entry.js' import { stripAbsolutePath } from './strip-absolute-path.js' import { stripTrailingSlashes } from './strip-trailing-slashes.js' -import { EntryTypeName } from './types.js' -import { - WarnData, - Warner, - WarnEvent, - warnMethod, -} from './warn-method.js' +import type { EntryTypeName } from './types.js' +import type { WarnData, Warner, WarnEvent } from './warn-method.js' +import { warnMethod } from './warn-method.js' import * as winchars from './winchars.js' const prefixPath = (path: string, prefix?: string) => { @@ -88,7 +84,7 @@ export class WriteEntry type?: EntryTypeName | 'Unsupported' linkpath?: string stat?: Stats - onWriteEntry?: (entry: WriteEntry) => any + onWriteEntry?: (entry: WriteEntry) => unknown #hadError: boolean = false @@ -107,8 +103,7 @@ export class WriteEntry this.noPax = !!opt.noPax this.noMtime = !!opt.noMtime this.mtime = opt.mtime - this.prefix = - opt.prefix ? normalizeWindowsPath(opt.prefix) : undefined + this.prefix = opt.prefix ? normalizeWindowsPath(opt.prefix) : undefined this.onWriteEntry = opt.onWriteEntry if (typeof opt.onwarn === 'function') { @@ -128,8 +123,8 @@ export class WriteEntry if (this.win32) { // force the \ to / normalization, since we might not *actually* // be on windows, but want \ to be considered a path separator. - this.path = winchars.decode(this.path.replace(/\\/g, '/')) - p = p.replace(/\\/g, '/') + this.path = winchars.decode(this.path.replaceAll(/\\/g, '/')) + p = p.replaceAll(/\\/g, '/') } this.absolute = normalizeWindowsPath( @@ -163,7 +158,7 @@ export class WriteEntry return warnMethod(this, code, message, data) } - emit(ev: keyof WarnEvent, ...data: any[]) { + emit(ev: keyof WarnEvent, ...data: unknown[]) { if (ev === 'error') { this.#hadError = true } @@ -255,9 +250,7 @@ export class WriteEntry ctime: this.portable ? undefined : this.header.ctime, gid: this.portable ? undefined : this.header.gid, mtime: - this.noMtime ? undefined : ( - this.mtime || this.header.mtime - ), + this.noMtime ? undefined : this.mtime || this.header.mtime, path: this[PREFIX](this.path), linkpath: this.type === 'Link' && this.linkpath !== undefined ? @@ -317,9 +310,7 @@ export class WriteEntry } /* c8 ignore stop */ this.type = 'Link' - this.linkpath = normalizeWindowsPath( - path.relative(this.cwd, linkpath), - ) + this.linkpath = normalizeWindowsPath(path.relative(this.cwd, linkpath)) this.stat.size = 0 this[HEADER]() this.end() @@ -332,8 +323,7 @@ export class WriteEntry } /* c8 ignore stop */ if (this.stat.nlink > 1) { - const linkKey = - `${this.stat.dev}:${this.stat.ino}` as LinkCacheKey + const linkKey = `${this.stat.dev}:${this.stat.ino}` as LinkCacheKey const linkpath = this.linkCache.get(linkKey) if (linkpath?.indexOf(this.cwd) === 0) { return this[HARDLINK](linkpath) @@ -397,7 +387,7 @@ export class WriteEntry /* c8 ignore start */ [CLOSE]( - cb: (er?: null | Error | NodeJS.ErrnoException) => any = () => {}, + cb: (er?: null | Error | NodeJS.ErrnoException) => unknown = () => {}, ) { /* c8 ignore stop */ if (this.fd !== undefined) fs.close(this.fd, cb) @@ -405,14 +395,11 @@ export class WriteEntry [ONREAD](bytesRead: number) { if (bytesRead <= 0 && this.remain > 0) { - const er = Object.assign( - new Error('encountered unexpected EOF'), - { - path: this.absolute, - syscall: 'read', - code: 'EOF', - }, - ) + const er = Object.assign(new Error('encountered unexpected EOF'), { + path: this.absolute, + syscall: 'read', + code: 'EOF', + }) return this[CLOSE](() => this.emit('error', er)) } @@ -465,7 +452,7 @@ export class WriteEntry } } - [AWAITDRAIN](cb: () => any) { + [AWAITDRAIN](cb: () => unknown) { this.once('drain', cb) } @@ -477,8 +464,8 @@ export class WriteEntry ): boolean write( chunk: Buffer | string, - encoding?: BufferEncoding | (() => any) | null, - cb?: () => any, + encoding?: BufferEncoding | (() => unknown) | null, + cb?: () => unknown, ): boolean { /* c8 ignore start - just junk to comply with NodeJS.WritableStream */ if (typeof encoding === 'function') { @@ -514,9 +501,7 @@ export class WriteEntry if (this.blockRemain) { super.write(Buffer.alloc(this.blockRemain)) } - return this[CLOSE](er => - er ? this.emit('error', er) : this.end(), - ) + return this[CLOSE](er => (er ? this.emit('error', er) : this.end())) } /* c8 ignore start */ @@ -571,18 +556,18 @@ export class WriteEntrySync extends WriteEntry implements Warner { if (threw) { try { this[CLOSE](() => {}) - } catch (er) {} + } catch {} } } } - [AWAITDRAIN](cb: () => any) { + [AWAITDRAIN](cb: () => unknown) { cb() } /* c8 ignore start */ [CLOSE]( - cb: (er?: null | Error | NodeJS.ErrnoException) => any = () => {}, + cb: (er?: null | Error | NodeJS.ErrnoException) => unknown = () => {}, ) { /* c8 ignore stop */ if (this.fd !== undefined) fs.closeSync(this.fd) @@ -620,16 +605,13 @@ export class WriteEntryTar ctime?: Date linkpath?: string size: number - onWriteEntry?: (entry: WriteEntry) => any + onWriteEntry?: (entry: WriteEntry) => unknown warn(code: string, message: string | Error, data: WarnData = {}) { return warnMethod(this, code, message, data) } - constructor( - readEntry: ReadEntry, - opt_: TarOptionsWithAliases = {}, - ) { + constructor(readEntry: ReadEntry, opt_: TarOptionsWithAliases = {}) { const opt = dealias(opt_) super() this.preservePaths = !!opt.preservePaths @@ -655,16 +637,13 @@ export class WriteEntryTar this.path = normalizeWindowsPath(readEntry.path) this.mode = - readEntry.mode !== undefined ? - this[MODE](readEntry.mode) - : undefined + readEntry.mode !== undefined ? this[MODE](readEntry.mode) : undefined this.uid = this.portable ? undefined : readEntry.uid this.gid = this.portable ? undefined : readEntry.gid this.uname = this.portable ? undefined : readEntry.uname this.gname = this.portable ? undefined : readEntry.gname this.size = readEntry.size - this.mtime = - this.noMtime ? undefined : opt.mtime || readEntry.mtime + this.mtime = this.noMtime ? undefined : opt.mtime || readEntry.mtime this.atime = this.portable ? undefined : readEntry.atime this.ctime = this.portable ? undefined : readEntry.ctime this.linkpath = @@ -765,8 +744,8 @@ export class WriteEntryTar ): boolean write( chunk: Buffer | string, - encoding?: BufferEncoding | (() => any) | null, - cb?: () => any, + encoding?: BufferEncoding | (() => unknown) | null, + cb?: () => unknown, ): boolean { /* c8 ignore start - just junk to comply with NodeJS.WritableStream */ if (typeof encoding === 'function') { @@ -817,7 +796,8 @@ export class WriteEntryTar chunk = Buffer.from(chunk, encoding ?? 'utf8') } if (cb) this.once('finish', cb) - chunk ? super.end(chunk, cb) : super.end(cb) + if (chunk) super.end(chunk, cb) + else super.end(cb) /* c8 ignore stop */ return this } diff --git a/test/create.ts b/test/create.ts index 3c3710c8..7cdb17ca 100644 --- a/test/create.ts +++ b/test/create.ts @@ -2,7 +2,8 @@ import fs from 'fs' import { mkdirp } from 'mkdirp' import path from 'path' import { rimraf } from 'rimraf' -import t, { Test } from 'tap' +import type { Test } from 'tap' +import t from 'tap' import { c, list, Pack, PackSync } from '../dist/esm/index.js' import { spawn } from 'child_process' //@ts-ignore @@ -302,8 +303,5 @@ t.test('transform a filename', async t => { }, ['README.md'], ).concat() - t.equal( - data.subarray(0, 'bloorg.md'.length).toString(), - 'bloorg.md', - ) + t.equal(data.subarray(0, 'bloorg.md'.length).toString(), 'bloorg.md') }) diff --git a/test/extract.ts b/test/extract.ts index 02224e0d..95214d6b 100644 --- a/test/extract.ts +++ b/test/extract.ts @@ -5,7 +5,8 @@ import nock from 'nock' import path from 'path' import { rimraf } from 'rimraf' import { pipeline as PL } from 'stream' -import t, { Test } from 'tap' +import type { Test } from 'tap' +import t from 'tap' import { fileURLToPath } from 'url' import { promisify } from 'util' import { extract as x } from '../dist/esm/extract.js' @@ -228,14 +229,8 @@ t.test('no file list', t => { }) const check = async (t: Test) => { - t.equal( - fs.lstatSync(path.resolve(dir, '1024-bytes.txt')).size, - 1024, - ) - t.equal( - fs.lstatSync(path.resolve(dir, '512-bytes.txt')).size, - 512, - ) + t.equal(fs.lstatSync(path.resolve(dir, '1024-bytes.txt')).size, 1024) + t.equal(fs.lstatSync(path.resolve(dir, '512-bytes.txt')).size, 512) t.equal(fs.lstatSync(path.resolve(dir, 'one-byte.txt')).size, 1) t.equal(fs.lstatSync(path.resolve(dir, 'zero-byte.txt')).size, 0) await rimraf(dir) @@ -295,14 +290,8 @@ t.test('read in itty bits', t => { }) const check = async (t: Test) => { - t.equal( - fs.lstatSync(path.resolve(dir, '1024-bytes.txt')).size, - 1024, - ) - t.equal( - fs.lstatSync(path.resolve(dir, '512-bytes.txt')).size, - 512, - ) + t.equal(fs.lstatSync(path.resolve(dir, '1024-bytes.txt')).size, 1024) + t.equal(fs.lstatSync(path.resolve(dir, '512-bytes.txt')).size, 512) t.equal(fs.lstatSync(path.resolve(dir, 'one-byte.txt')).size, 1) t.equal(fs.lstatSync(path.resolve(dir, 'zero-byte.txt')).size, 0) await rimraf(dir) @@ -319,15 +308,12 @@ t.test('read in itty bits', t => { }) t.test('async cb', t => { - return x( - { file: file, cwd: dir, maxReadSize: maxReadSize }, - er => { - if (er) { - throw er - } - return check(t) - }, - ) + return x({ file: file, cwd: dir, maxReadSize: maxReadSize }, er => { + if (er) { + throw er + } + return check(t) + }) }) t.end() diff --git a/test/get-write-flag.js b/test/get-write-flag.js index 1e81ba20..caad94e3 100644 --- a/test/get-write-flag.js +++ b/test/get-write-flag.js @@ -64,9 +64,7 @@ switch (process.argv[2]) { t.spawn(node, [__filename, 'unix'], { env: { ...process.env, - ...(platform === 'win32' ? - { __FAKE_PLATFORM__: 'linux' } - : {}), + ...(platform === 'win32' ? { __FAKE_PLATFORM__: 'linux' } : {}), }, }) } diff --git a/test/ghsa-8qq5-rm4j-mr97.ts b/test/ghsa-8qq5-rm4j-mr97.ts index 5b18eeeb..5fc6f43b 100644 --- a/test/ghsa-8qq5-rm4j-mr97.ts +++ b/test/ghsa-8qq5-rm4j-mr97.ts @@ -1,9 +1,4 @@ -import { - lstatSync, - readFileSync, - readlinkSync, - writeFileSync, -} from 'fs' +import { lstatSync, readFileSync, readlinkSync, writeFileSync } from 'fs' import { resolve } from 'path' import t from 'tap' import { Header, x } from 'tar' diff --git a/test/header.js b/test/header.js index 07f64f53..e5de67dc 100644 --- a/test/header.js +++ b/test/header.js @@ -282,10 +282,7 @@ t.test('prefix handling', t => { 'header from buffer', ) - t.equal( - b2.toString().replace(/\0.*$/, ''), - 'e/p/-/p/a/t/h/foo.txt', - ) + t.equal(b2.toString().replace(/\0.*$/, ''), 'e/p/-/p/a/t/h/foo.txt') t.equal( b2.subarray(345).toString().replace(/\0.*$/, ''), 'r/e/a/l/l/y/-' + @@ -670,16 +667,13 @@ t.test('gnutar-generated 10gb file size', t => { t.end() }) -t.test( - 'tarmageddon, ensure that Header prioritizes Pax size', - async t => { - const h = new Header({ - path: 'file.txt', - size: 0, - }) - h.encode() - t.equal(h.size, 0, 'size is zero in raw ustar header') - const hPax = new Header(h.block, 0, { size: 123 }) - t.equal(hPax.size, 123, 'if size is set in pax, takes priority') - }, -) +t.test('tarmageddon, ensure that Header prioritizes Pax size', async t => { + const h = new Header({ + path: 'file.txt', + size: 0, + }) + h.encode() + t.equal(h.size, 0, 'size is zero in raw ustar header') + const hPax = new Header(h.block, 0, { size: 123 }) + t.equal(hPax.size, 123, 'if size is set in pax, takes priority') +}) diff --git a/test/large-numbers.js b/test/large-numbers.js index c84956d2..52eb47fd 100644 --- a/test/large-numbers.js +++ b/test/large-numbers.js @@ -71,10 +71,7 @@ t.test('encode', t => { t.test('allocUnsafe', t => { t.plan(cases.size) cases.forEach((value, hex) => - t.equal( - encode(value, Buffer.allocUnsafe(12)).toString('hex'), - hex, - ), + t.equal(encode(value, Buffer.allocUnsafe(12)).toString('hex'), hex), ) }) }) diff --git a/test/list.ts b/test/list.ts index 90cbb5b2..729622de 100644 --- a/test/list.ts +++ b/test/list.ts @@ -1,12 +1,14 @@ -import fs, { readFileSync, Stats } from 'fs' +import type { Stats } from 'fs' +import fs, { readFileSync } from 'fs' //@ts-ignore import mutateFS from 'mutate-fs' import { dirname, resolve } from 'path' -import t, { Test } from 'tap' +import type { Test } from 'tap' +import t from 'tap' import { fileURLToPath } from 'url' import { list } from '../dist/esm/list.js' import { Parser } from '../dist/esm/parse.js' -import { ReadEntry } from '../dist/esm/read-entry.js' +import type { ReadEntry } from '../dist/esm/read-entry.js' import { makeTar } from './fixtures/make-tar.js' const __filename = fileURLToPath(import.meta.url) @@ -35,8 +37,7 @@ t.test('basic', t => { t.test('file maxReadSize=' + maxReadSize, t => { t.test('sync', t => { const actual: string[] = [] - const onReadEntry = (entry: ReadEntry) => - actual.push(entry.path) + const onReadEntry = (entry: ReadEntry) => actual.push(entry.path) list({ file: file, sync: true, @@ -48,8 +49,7 @@ t.test('basic', t => { t.test('async promise', async t => { const actual: string[] = [] - const onReadEntry = (entry: ReadEntry) => - actual.push(entry.path) + const onReadEntry = (entry: ReadEntry) => actual.push(entry.path) return await list({ file, onReadEntry, @@ -59,8 +59,7 @@ t.test('basic', t => { t.test('async cb', t => { const actual: string[] = [] - const onReadEntry = (entry: ReadEntry) => - actual.push(entry.path) + const onReadEntry = (entry: ReadEntry) => actual.push(entry.path) list( { file: file, @@ -83,8 +82,7 @@ t.test('basic', t => { t.test('stream', t => { t.test('sync', t => { const actual: string[] = [] - const onReadEntry = (entry: ReadEntry) => - actual.push(entry.path) + const onReadEntry = (entry: ReadEntry) => actual.push(entry.path) const l = list({ sync: true, onReadEntry }) l.end(fs.readFileSync(file)) return check(actual, t) @@ -92,8 +90,7 @@ t.test('basic', t => { t.test('async', t => { const actual: string[] = [] - const onReadEntry = (entry: ReadEntry) => - actual.push(entry.path) + const onReadEntry = (entry: ReadEntry) => actual.push(entry.path) const l = list() l.on('entry', onReadEntry) l.on('end', _ => check(actual, t).then(_ => t.end())) @@ -136,8 +133,7 @@ t.test('basic', t => { t.test('no filter function, stream', t => { const check = () => t.same(actual, expect) const actual: string[] = [] - const onReadEntry = (entry: ReadEntry) => - actual.push(entry.path) + const onReadEntry = (entry: ReadEntry) => actual.push(entry.path) fs.createReadStream(file).pipe( list(fileList) .on('entry', onReadEntry) @@ -303,46 +299,44 @@ t.test('reduce file size while synchronously reading', async t => { const setup = async (t: Test) => { const dir = t.testdir({ 'file.tar': data }) const file = resolve(dir, 'file.tar') - const { list } = await t.mockImport< - typeof import('../src/list.js') - >('../src/list.js', { - 'node:fs': t.createMock(fs, { - fstatSync: (fd: number): Stats => { - const st = fs.fstatSync(fd) - // truncate the file before we have a chance to read - fs.writeFileSync(file, truncData) - return st - }, - }), - }) + const { list } = await t.mockImport( + '../src/list.js', + { + 'node:fs': t.createMock(fs, { + fstatSync: (fd: number): Stats => { + const st = fs.fstatSync(fd) + // truncate the file before we have a chance to read + fs.writeFileSync(file, truncData) + return st + }, + }), + }, + ) return { file, list } } - t.test( - 'gutcheck, reading normally reads the whole file', - async t => { - const dir = t.testdir({ 'file.tar': data }) - const file = resolve(dir, 'file.tar') - const entries: string[] = [] - list({ - file, - sync: true, - maxReadSize: dataLen + 1, - onReadEntry: e => entries.push(e.path), - }) - t.strictSame(entries, ['a', 'b']) + t.test('gutcheck, reading normally reads the whole file', async t => { + const dir = t.testdir({ 'file.tar': data }) + const file = resolve(dir, 'file.tar') + const entries: string[] = [] + list({ + file, + sync: true, + maxReadSize: dataLen + 1, + onReadEntry: e => entries.push(e.path), + }) + t.strictSame(entries, ['a', 'b']) - entries.length = 0 - list({ - file, - sync: true, - maxReadSize: dataLen - 1, - onReadEntry: e => entries.push(e.path), - }) - t.strictSame(entries, ['a', 'b']) - }, - ) + entries.length = 0 + list({ + file, + sync: true, + maxReadSize: dataLen - 1, + onReadEntry: e => entries.push(e.path), + }) + t.strictSame(entries, ['a', 'b']) + }) t.test('read in one go', async t => { const { file, list } = await setup(t) diff --git a/test/load-all.js b/test/load-all.js index 111a5fb6..f1bbf1e5 100644 --- a/test/load-all.js +++ b/test/load-all.js @@ -9,7 +9,7 @@ const lib = path.resolve(__dirname, '../dist/esm') await Promise.all( fs .readdirSync(lib) - .filter(f => /\.js$/.test(f)) + .filter(f => f.endsWith('.js')) .map(f => import('../dist/esm/' + f)), ) diff --git a/test/normalize-unicode.js b/test/normalize-unicode.js index e006ca24..3689bccc 100644 --- a/test/normalize-unicode.js +++ b/test/normalize-unicode.js @@ -11,9 +11,7 @@ const fakePlatform = process.env.TESTING_TAR_FAKE_PLATFORM const cafe1 = Buffer.from([0x63, 0x61, 0x66, 0xc3, 0xa9]).toString() // cafe with a ` -const cafe2 = Buffer.from([ - 0x63, 0x61, 0x66, 0x65, 0xcc, 0x81, -]).toString() +const cafe2 = Buffer.from([0x63, 0x61, 0x66, 0x65, 0xcc, 0x81]).toString() t.equal( normalizeUnicode(cafe1), diff --git a/test/pack.js b/test/pack.js index d68e1a60..a73f16b7 100644 --- a/test/pack.js +++ b/test/pack.js @@ -93,10 +93,7 @@ t.test('pack a file', t => { } t.equal(sync.subarray(512).length, data.subarray(512).length) - t.equal( - sync.subarray(512).toString(), - data.subarray(512).toString(), - ) + t.equal(sync.subarray(512).toString(), data.subarray(512).toString()) const hs = new Header(sync) t.match(hs, expect) t.strictSame( @@ -140,10 +137,7 @@ t.test('pack a file with a prefix', t => { .add('.dotfile') .end() .read() - t.equal( - sync.subarray(512).toString(), - data.subarray(512).toString(), - ) + t.equal(sync.subarray(512).toString(), data.subarray(512).toString()) const hs = new Header(sync) t.match(hs, expect) t.end() @@ -198,10 +192,7 @@ t.test('portable pack a dir', t => { t.equal(syncgz[9], 255, 'gzip OS flag set to "unknown"') const sync = new miniz.Gunzip().end(zipped).read() - t.equal( - sync.subarray(512).toString(), - data.subarray(512).toString(), - ) + t.equal(sync.subarray(512).toString(), data.subarray(512).toString()) const hs = new Header(sync) t.match(hs, expect) @@ -267,14 +258,8 @@ t.test('use process cwd if cwd not specified', t => { t.equal(data.length, 2048) t.match(data.subarray(1024).toString(), /^\0{1024}$/) - const sync = new PackSync({ cwd: files }) - .add('dir') - .end() - .read() - t.equal( - sync.subarray(512).toString(), - data.subarray(512).toString(), - ) + const sync = new PackSync({ cwd: files }).add('dir').end().read() + t.equal(sync.subarray(512).toString(), data.subarray(512).toString()) const hs = new Header(sync) t.match(hs, expect) @@ -342,10 +327,7 @@ t.test('filter', t => { .add('dir') .end() .read() - t.equal( - sync.subarray(512).toString(), - data.subarray(512).toString(), - ) + t.equal(sync.subarray(512).toString(), data.subarray(512).toString()) const hs = new Header(sync) t.match(hs, expect) t.end() @@ -493,10 +475,8 @@ t.test('gzip, also a very deep path', t => { 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.*$/, ''), - ) + } else if (entries.at(-1)[0] === 'File') { + entries.at(-1).push(slice.toString().replace(/\0.*$/, '')) } } @@ -521,14 +501,8 @@ t.test('gzip, also a very deep path', t => { ['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/'], + ['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/', @@ -619,10 +593,8 @@ t.test('brotli, also a very deep path', t => { 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.*$/, ''), - ) + } else if (entries.at(-1)[0] === 'File') { + entries.at(-1).push(slice.toString().replace(/\0.*$/, '')) } } @@ -647,14 +619,8 @@ t.test('brotli, also a very deep path', t => { ['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/'], + ['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/', @@ -744,10 +710,8 @@ t.test('zstd, also a very deep path', t => { 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.*$/, ''), - ) + } else if (entries.at(-1)[0] === 'File') { + entries.at(-1).push(slice.toString().replace(/\0.*$/, '')) } } @@ -772,14 +736,8 @@ t.test('zstd, also a very deep path', t => { ['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/'], + ['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/', @@ -871,10 +829,8 @@ t.test('very deep gzip path, sync', t => { 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.*$/, ''), - ) + } else if (entries.at(-1)[0] === 'File') { + entries.at(-1).push(slice.toString().replace(/\0.*$/, '')) } } @@ -901,14 +857,8 @@ t.test('very deep gzip path, sync', t => { ['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/'], + ['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/', @@ -992,10 +942,8 @@ t.test('very deep brotli path, sync', t => { 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.*$/, ''), - ) + } else if (entries.at(-1)[0] === 'File') { + entries.at(-1).push(slice.toString().replace(/\0.*$/, '')) } } @@ -1022,14 +970,8 @@ t.test('very deep brotli path, sync', t => { ['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/'], + ['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/', @@ -1112,10 +1054,8 @@ t.test('very deep zstd path, sync', t => { 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.*$/, ''), - ) + } else if (entries.at(-1)[0] === 'File') { + entries.at(-1).push(slice.toString().replace(/\0.*$/, '')) } } @@ -1142,14 +1082,8 @@ t.test('very deep zstd path, sync', t => { ['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/'], + ['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/', @@ -1230,10 +1164,7 @@ t.test('emit error when stat fail', t => { t.test('readdir fail', t => { t.teardown(mutateFS.fail('readdir', new Error('xyz'))) - t.throws( - _ => new PackSync({ cwd: files }).add('dir'), - new Error('xyz'), - ) + t.throws(_ => new PackSync({ cwd: files }).add('dir'), new Error('xyz')) new Pack({ cwd: files }).add('dir').on('error', e => { t.match(e, { message: 'xyz' }) @@ -1275,10 +1206,7 @@ t.test('pipe into a slow reader', t => { } t.match(h, expect) t.equal(data.length, 21504) - t.match( - data.subarray(data.length - 1024).toString(), - /^\0{1024}$/, - ) + t.match(data.subarray(data.length - 1024).toString(), /^\0{1024}$/) t.end() }) }) @@ -1286,9 +1214,7 @@ t.test('pipe into a slow reader', t => { t.test('pipe into a slow gzip reader', t => { const out = [] const mp2 = new miniz.Unzip() - const p = new Pack({ cwd: files, gzip: true }) - .add('long-path') - .end() + const p = new Pack({ cwd: files, gzip: true }).add('long-path').end() p.pause() class SlowStream extends EE { @@ -1339,10 +1265,7 @@ t.test('pipe into a slow gzip reader', t => { } t.match(h, expect) t.equal(data.length, 21504) - t.match( - data.subarray(data.length - 1024).toString(), - /^\0{1024}$/, - ) + t.match(data.subarray(data.length - 1024).toString(), /^\0{1024}$/) t.end() }) }) @@ -1371,14 +1294,8 @@ t.test('ignores mid-queue', t => { p.on('data', c => out.push(c)) p.on('end', _ => { const data = Buffer.concat(out) - t.equal( - data.subarray(0, 100).toString().replace(/\0.*$/, ''), - './', - ) - const file = data - .subarray(512, 612) - .toString() - .replace(/\0.*$/, '') + t.equal(data.subarray(0, 100).toString().replace(/\0.*$/, ''), './') + const file = data.subarray(512, 612).toString().replace(/\0.*$/, '') t.not(files.indexOf(file), -1) t.end() }) @@ -1567,10 +1484,7 @@ t.test('pack ReadEntries', t => { const data = Buffer.concat(out) t.equal(data.length, 2048) t.match(data.subarray(1024).toString(), /^\0+$/) - t.equal( - data.subarray(0, 100).toString().replace(/\0.*$/, ''), - 'x', - ) + t.equal(data.subarray(0, 100).toString().replace(/\0.*$/, ''), 'x') t.equal(data.subarray(512, 514).toString(), 'x\0') t.end() }) @@ -1595,10 +1509,7 @@ t.test('pack ReadEntries', t => { const data = Buffer.concat(out) t.equal(data.length, 2048) t.match(data.subarray(1024).toString(), /^\0+$/) - t.equal( - data.subarray(0, 100).toString().replace(/\0.*$/, ''), - 'y/x', - ) + t.equal(data.subarray(0, 100).toString().replace(/\0.*$/, ''), 'y/x') t.equal(data.subarray(512, 514).toString(), 'x\0') t.end() }) @@ -1639,10 +1550,7 @@ t.test('pack ReadEntries', t => { const data = Buffer.concat(out) t.equal(data.length, 2048) t.match(data.subarray(1024).toString(), /^\0+$/) - t.equal( - data.subarray(0, 100).toString().replace(/\0.*$/, ''), - 'x', - ) + t.equal(data.subarray(0, 100).toString().replace(/\0.*$/, ''), 'x') t.equal(data.subarray(512, 514).toString(), 'x\0') t.end() }) @@ -1708,10 +1616,7 @@ t.test('fs.open fails', t => { t.test('sync', t => { t.plan(1) - t.throws( - _ => new PackSync({ cwd: files }).end('one-byte.txt'), - poop, - ) + t.throws(_ => new PackSync({ cwd: files }).end('one-byte.txt'), poop) }) t.end() @@ -1744,15 +1649,13 @@ const write = opts => }) t.test('padding works regardless of arite/add order', t => - Promise.all([ - write({ before: true }), - write({ before: false }), - ]).then(res => - t.equal( - res[0], - res[1], - 'length is the same regardless of write/add order', - ), + Promise.all([write({ before: true }), write({ before: false })]).then( + res => + t.equal( + res[0], + res[1], + 'length is the same regardless of write/add order', + ), ), ) @@ -1785,10 +1688,7 @@ t.test('prefix and subdirs', t => { const check = (out, t) => { const data = Buffer.concat(out) expect.forEach((e, i) => - t.equal( - e, - data.subarray(i * 512, i * 512 + e.length).toString(), - ), + t.equal(e, data.subarray(i * 512, i * 512 + e.length).toString()), ) t.end() } @@ -1874,10 +1774,7 @@ t.test('prefix and hard links', t => { const data = Buffer.concat(out) expect.forEach((e, i) => { if (typeof e === 'string') { - t.equal( - data.subarray(i * 512, i * 512 + e.length).toString(), - e, - ) + t.equal(data.subarray(i * 512, i * 512 + e.length).toString(), e) } else { t.match(new Header(data.subarray(i * 512, (i + 1) * 512)), e) } diff --git a/test/parse.js b/test/parse.js index 57e15e21..43d316f2 100644 --- a/test/parse.js +++ b/test/parse.js @@ -35,8 +35,7 @@ t.test('fixture tests', t => { let ok = true let cursor = 0 p.on('entry', entry => { - ok = - ok && t.match(['entry', entry], expect[cursor++], entry.path) + ok = ok && t.match(['entry', entry], expect[cursor++], entry.path) if (slow) { setTimeout(() => entry.resume()) } else { @@ -49,12 +48,11 @@ t.test('fixture tests', t => { t.match( ['ignoredEntry', entry], expect[cursor++], - 'ignored: ' + entry.path, + `ignored: ${entry.path}`, ) }) p.on('warn', (c, message, _data) => { - ok = - ok && t.match(['warn', c, message], expect[cursor++], 'warn') + ok = ok && t.match(['warn', c, message], expect[cursor++], 'warn') }) p.on('nullBlock', () => { ok = ok && t.match(['nullBlock'], expect[cursor++], 'null') @@ -84,15 +82,7 @@ t.test('fixture tests', t => { const tardata = fs.readFileSync(file) const base = path.basename(file, '.tar') t.test( - 'file=' + - base + - '.tar' + - ' maxmeta=' + - maxMeta + - ' filter=' + - filter + - ' strict=' + - strict, + `file=${base}.tar maxmeta=${maxMeta} filter=${filter} strict=${strict}`, t => { const o = (maxMeta ? '-meta-' + maxMeta : '') + @@ -131,45 +121,38 @@ t.test('fixture tests', t => { const p = new Parser({ maxMetaEntrySize: maxMeta, filter: - filter ? - (_path, entry) => entry.size % 2 !== 0 - : undefined, + filter ? (_path, entry) => entry.size % 2 !== 0 : undefined, strict: strict, }) trackEvents(t, expect, p) p.end(tardata.toString('hex'), 'hex', () => {}) }) - t.test( - 'uncompressed one byte at a time, filename .tbr', - t => { - const bs = new ByteStream() - const opt = - maxMeta || filter || strict ? - { - maxMetaEntrySize: maxMeta, - filter: - filter ? - (_path, entry) => entry.size % 2 !== 0 - : undefined, - strict: strict, - file: 'example.tbr', - } - : undefined - const bp = new Parser(opt) - trackEvents(t, expect, bp) - bs.pipe(bp) - bs.end(tardata) - }, - ) + t.test('uncompressed one byte at a time, filename .tbr', t => { + const bs = new ByteStream() + const opt = + maxMeta || filter || strict ? + { + maxMetaEntrySize: maxMeta, + filter: + filter ? + (_path, entry) => entry.size % 2 !== 0 + : undefined, + strict: strict, + file: 'example.tbr', + } + : undefined + const bp = new Parser(opt) + trackEvents(t, expect, bp) + bs.pipe(bp) + bs.end(tardata) + }) t.test('uncompressed all at once, filename .tar.br', t => { const p = new Parser({ maxMetaEntrySize: maxMeta, filter: - filter ? - (_path, entry) => entry.size % 2 !== 0 - : undefined, + filter ? (_path, entry) => entry.size % 2 !== 0 : undefined, strict: strict, file: 'example.tar.br', }) @@ -181,9 +164,7 @@ t.test('fixture tests', t => { const p = new Parser({ maxMetaEntrySize: maxMeta, filter: - filter ? - (_path, entry) => entry.size % 2 !== 0 - : undefined, + filter ? (_path, entry) => entry.size % 2 !== 0 : undefined, strict: strict, }) trackEvents(t, expect, p) @@ -194,9 +175,7 @@ t.test('fixture tests', t => { const p = new Parser({ maxMetaEntrySize: maxMeta, filter: - filter ? - (_path, entry) => entry.size % 2 !== 0 - : undefined, + filter ? (_path, entry) => entry.size % 2 !== 0 : undefined, strict: strict, file: 'example.tbr', }) @@ -210,9 +189,7 @@ t.test('fixture tests', t => { const bp = new Parser({ maxMetaEntrySize: maxMeta, filter: - filter ? - (_path, entry) => entry.size % 2 !== 0 - : undefined, + filter ? (_path, entry) => entry.size % 2 !== 0 : undefined, strict: strict, }) trackEvents(t, expect, bp) @@ -220,30 +197,23 @@ t.test('fixture tests', t => { bs.end(zlib.gzipSync(tardata)) }) - t.test( - 'compress with brotli based on filename .tar.br', - t => { - const p = new Parser({ - maxMetaEntrySize: maxMeta, - filter: - filter ? - (_path, entry) => entry.size % 2 !== 0 - : undefined, - strict: strict, - file: 'example.tar.br', - }) - trackEvents(t, expect, p) - p.end(zlib.brotliCompressSync(tardata)) - }, - ) + t.test('compress with brotli based on filename .tar.br', t => { + const p = new Parser({ + maxMetaEntrySize: maxMeta, + filter: + filter ? (_path, entry) => entry.size % 2 !== 0 : undefined, + strict: strict, + file: 'example.tar.br', + }) + trackEvents(t, expect, p) + p.end(zlib.brotliCompressSync(tardata)) + }) t.test('compress with brotli based on filename .tbr', t => { const p = new Parser({ maxMetaEntrySize: maxMeta, filter: - filter ? - (_path, entry) => entry.size % 2 !== 0 - : undefined, + filter ? (_path, entry) => entry.size % 2 !== 0 : undefined, strict: strict, file: 'example.tbr', }) @@ -255,9 +225,7 @@ t.test('fixture tests', t => { const p = new Parser({ maxMetaEntrySize: maxMeta, filter: - filter ? - (_path, entry) => entry.size % 2 !== 0 - : undefined, + filter ? (_path, entry) => entry.size % 2 !== 0 : undefined, strict: strict, brotli: {}, }) @@ -270,9 +238,7 @@ t.test('fixture tests', t => { const bp = new Parser({ maxMetaEntrySize: maxMeta, filter: - filter ? - (_path, entry) => entry.size % 2 !== 0 - : undefined, + filter ? (_path, entry) => entry.size % 2 !== 0 : undefined, strict: strict, brotli: {}, }) @@ -286,9 +252,7 @@ t.test('fixture tests', t => { const bp = new Parser({ maxMetaEntrySize: maxMeta, filter: - filter ? - (_path, entry) => entry.size % 2 !== 0 - : undefined, + filter ? (_path, entry) => entry.size % 2 !== 0 : undefined, strict: strict, file: 'example.tbr', }) @@ -301,9 +265,7 @@ t.test('fixture tests', t => { const p = new Parser({ maxMetaEntrySize: maxMeta, filter: - filter ? - (_path, entry) => entry.size % 2 !== 0 - : undefined, + filter ? (_path, entry) => entry.size % 2 !== 0 : undefined, strict: strict, file: 'example.tar.zst', }) @@ -315,9 +277,7 @@ t.test('fixture tests', t => { const p = new Parser({ maxMetaEntrySize: maxMeta, filter: - filter ? - (_path, entry) => entry.size % 2 !== 0 - : undefined, + filter ? (_path, entry) => entry.size % 2 !== 0 : undefined, strict: strict, file: 'example.tzst', }) @@ -329,9 +289,7 @@ t.test('fixture tests', t => { const p = new Parser({ maxMetaEntrySize: maxMeta, filter: - filter ? - (_path, entry) => entry.size % 2 !== 0 - : undefined, + filter ? (_path, entry) => entry.size % 2 !== 0 : undefined, strict: strict, zstd: {}, }) @@ -344,9 +302,7 @@ t.test('fixture tests', t => { const bp = new Parser({ maxMetaEntrySize: maxMeta, filter: - filter ? - (_path, entry) => entry.size % 2 !== 0 - : undefined, + filter ? (_path, entry) => entry.size % 2 !== 0 : undefined, strict: strict, zstd: {}, }) @@ -360,9 +316,7 @@ t.test('fixture tests', t => { const bp = new Parser({ maxMetaEntrySize: maxMeta, filter: - filter ? - (_path, entry) => entry.size % 2 !== 0 - : undefined, + filter ? (_path, entry) => entry.size % 2 !== 0 : undefined, strict: strict, file: 'example.tzst', }) @@ -375,16 +329,11 @@ t.test('fixture tests', t => { const p = new Parser({ maxMetaEntrySize: maxMeta, filter: - filter ? - (_path, entry) => entry.size % 2 !== 0 - : undefined, + filter ? (_path, entry) => entry.size % 2 !== 0 : undefined, strict: strict, }) trackEvents(t, expect, p, true) - const first = tardata.subarray( - 0, - Math.floor(tardata.length / 2), - ) + const first = tardata.subarray(0, Math.floor(tardata.length / 2)) p.write(first.toString('hex'), 'hex') process.nextTick(() => p.end(tardata.subarray(Math.floor(tardata.length / 2))), @@ -626,7 +575,6 @@ t.test('drain event timings', t => { } }) - let interval const go = () => { const d = data.shift() if (d === undefined) { @@ -649,11 +597,7 @@ t.test('drain event timings', t => { } if ( - !t.equal( - p.write(hunks[1]), - false, - 'write should return false: ' + d, - ) + !t.equal(p.write(hunks[1]), false, 'write should return false: ' + d) ) { return t.end() } @@ -667,7 +611,6 @@ t.test('drain event timings', t => { p.once('drain', go) p.on('end', () => { - clearInterval(interval) t.ok(sawOndone) t.end() }) @@ -951,14 +894,9 @@ t.test('header that throws', t => { }) h.encode() const buf = h.block - const bad = Buffer.from([ - 0x81, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - ]) + const bad = Buffer.from([0x81, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff]) bad.copy(buf, 100) - t.throws( - () => new Header(buf), - 'the header with that buffer throws', - ) + t.throws(() => new Header(buf), 'the header with that buffer throws') p.write(buf) }) diff --git a/test/pax.js b/test/pax.js index ea325b37..3e19f057 100644 --- a/test/pax.js +++ b/test/pax.js @@ -155,7 +155,6 @@ t.test('parse', t => { comment: undefined, gid: undefined, gname: undefined, - uname: undefined, linkpath: undefined, path: 'ab', size: undefined, @@ -171,7 +170,6 @@ t.test('parse', t => { t.same(Pax.parse('9 gid=20\n9 path=x\n'), { atime: undefined, - mtime: undefined, ctime: undefined, charset: undefined, comment: undefined, diff --git a/test/replace.ts b/test/replace.ts index b7b5194d..acc8d36a 100644 --- a/test/replace.ts +++ b/test/replace.ts @@ -1,4 +1,5 @@ -import t, { Test } from 'tap' +import type { Test } from 'tap' +import t from 'tap' import { replace as r } from '../dist/esm/replace.js' import path, { dirname, resolve } from 'path' import fs from 'fs' @@ -42,10 +43,7 @@ t.test('basic file add to archive (good or truncated)', t => { c.on('close', (code, signal) => { t.equal(code, 0) t.equal(signal, null) - const actual = Buffer.concat(out) - .toString() - .trim() - .split(/\r?\n/) + const actual = Buffer.concat(out).toString().trim().split(/\r?\n/) t.same(actual, [ '1024-bytes.txt', '512-bytes.txt', @@ -213,9 +211,7 @@ t.test('cannot append to gzipped archives', async t => { const file = resolve(dir, 'compressed.tgz') const expect = new Error('cannot append to compressed archives') - const expectT = new TypeError( - 'cannot append to compressed archives', - ) + const expectT = new TypeError('cannot append to compressed archives') t.throws( () => @@ -260,9 +256,7 @@ t.test('cannot append to brotli compressed archives', async t => { const file = resolve(dir, 'compressed.tbr') const expect = new Error('cannot append to compressed archives') - const expectT = new TypeError( - 'cannot append to compressed archives', - ) + const expectT = new TypeError('cannot append to compressed archives') t.throws( () => @@ -300,9 +294,7 @@ t.test('cannot append to zstd compressed archives', async t => { const file = resolve(dir, 'compressed.tzst') const expect = new Error('cannot append to compressed archives') - const expectT = new TypeError( - 'cannot append to compressed archives', - ) + const expectT = new TypeError('cannot append to compressed archives') t.throws( () => @@ -395,10 +387,7 @@ t.test('mtime cache', async t => { c.on('close', (code, signal) => { t.equal(code, 0) t.equal(signal, null) - const actual = Buffer.concat(out) - .toString() - .trim() - .split(/\r?\n/) + const actual = Buffer.concat(out).toString().trim().split(/\r?\n/) t.same(actual, [ '1024-bytes.txt', '512-bytes.txt', diff --git a/test/strip-absolute-path.js b/test/strip-absolute-path.js index 59529d6f..38ea1c59 100644 --- a/test/strip-absolute-path.js +++ b/test/strip-absolute-path.js @@ -11,18 +11,11 @@ t.test('basic', t => { 'c:///a/b/c': ['c:///', 'a/b/c'], '\\\\foo\\bar\\baz': ['\\\\foo\\bar\\', 'baz'], '//foo//bar//baz': ['//', 'foo//bar//baz'], - 'c:\\c:\\c:\\c:\\\\d:\\e/f/g': [ - 'c:\\c:\\c:\\c:\\\\d:\\', - 'e/f/g', - ], + 'c:\\c:\\c:\\c:\\\\d:\\e/f/g': ['c:\\c:\\c:\\c:\\\\d:\\', 'e/f/g'], } for (const [input, [root, stripped]] of Object.entries(cases)) { - t.strictSame( - stripAbsolutePath(input, cwd), - [root, stripped], - input, - ) + t.strictSame(stripAbsolutePath(input, cwd), [root, stripped], input) } t.end() }) @@ -47,10 +40,7 @@ t.test('drive-local paths', async t => { 'c:///a/b/c': ['c:///', 'a/b/c'], '\\\\foo\\bar\\baz': ['\\\\foo\\bar\\', 'baz'], '//foo//bar//baz': ['//', 'foo//bar//baz'], - 'c:\\c:\\c:\\c:\\\\d:\\e/f/g': [ - 'c:\\c:\\c:\\c:\\\\d:\\', - 'e/f/g', - ], + 'c:\\c:\\c:\\c:\\\\d:\\e/f/g': ['c:\\c:\\c:\\c:\\\\d:\\', 'e/f/g'], 'c:..\\system\\explorer.exe': ['c:', '..\\system\\explorer.exe'], 'd:..\\..\\unsafe\\land': ['d:', '..\\..\\unsafe\\land'], 'c:foo': ['c:', 'foo'], @@ -60,11 +50,7 @@ t.test('drive-local paths', async t => { } for (const [input, [root, stripped]] of Object.entries(cases)) { if ( - !t.strictSame( - stripAbsolutePath(input, cwd), - [root, stripped], - input, - ) + !t.strictSame(stripAbsolutePath(input, cwd), [root, stripped], input) ) { break } diff --git a/test/unpack.js b/test/unpack.js index 0509fc61..29cfef4b 100644 --- a/test/unpack.js +++ b/test/unpack.js @@ -49,8 +49,7 @@ t.test('basic file unpack tests', t => { 'utf8.tar': { '🌟.txt': '🌟✧✩⭐︎✪✫✬✭✮⚝✯✰✵✶✷✸✹❂⭑⭒★☆✡☪✴︎✦✡️🔯✴️🌠\n', 'Ω.txt': 'Ω', - 'long-path/r/e/a/l/l/y/-/d/e/e/p/-/f/o/l/d/e/r/-/p/a/t/h/Ω.txt': - 'Ω', + 'long-path/r/e/a/l/l/y/-/d/e/e/p/-/f/o/l/d/e/r/-/p/a/t/h/Ω.txt': 'Ω', }, 'file.tar': { 'one-byte.txt': 'a', @@ -77,8 +76,7 @@ t.test('basic file unpack tests', t => { 'cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc', 'long-path/r/e/a/l/l/y/-/d/e/e/p/-/f/o/l/d/e/r/-/p/a/t/h/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxcccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc': 'cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc', - 'long-path/r/e/a/l/l/y/-/d/e/e/p/-/f/o/l/d/e/r/-/p/a/t/h/Ω.txt': - 'Ω', + 'long-path/r/e/a/l/l/y/-/d/e/e/p/-/f/o/l/d/e/r/-/p/a/t/h/Ω.txt': 'Ω', }, } @@ -201,9 +199,7 @@ t.test('links!', t => { const unpack = new Unpack({ cwd: dir }) let finished = false unpack.on('finish', () => (finished = true)) - unpack.on('close', () => - t.ok(finished, 'emitted finish before close'), - ) + unpack.on('close', () => t.ok(finished, 'emitted finish before close')) unpack.on('close', () => check(t)) unpack.end(data) }) @@ -224,9 +220,7 @@ t.test('links!', t => { const unpack = new Unpack({ cwd: dir, strip: 1 }) let finished = false unpack.on('finish', () => (finished = true)) - unpack.on('close', () => - t.ok(finished, 'emitted finish before close'), - ) + unpack.on('close', () => t.ok(finished, 'emitted finish before close')) unpack.on('close', () => checkForStrip(t)) unpack.end(stripData) }) @@ -241,9 +235,7 @@ t.test('links!', t => { const unpack = new Unpack({ cwd: dir, strip: 3 }) let finished = false unpack.on('finish', () => (finished = true)) - unpack.on('close', () => - t.ok(finished, 'emitted finish before close'), - ) + unpack.on('close', () => t.ok(finished, 'emitted finish before close')) unpack.on('close', () => checkForStrip3(t)) unpack.end(stripData) }) @@ -502,10 +494,7 @@ t.test( fs.lstatSync(cwd + '/d/i/r/symlink').isSymbolicLink(), 'got symlink', ) - t.ok( - fs.lstatSync(cwd + '/d/i/r/dir/x').isFile(), - 'x thru link', - ) + t.ok(fs.lstatSync(cwd + '/d/i/r/dir/x').isFile(), 'x thru link') t.ok( fs.lstatSync(cwd + '/d/i/r/symlink/x').isFile(), 'x thru link', @@ -532,10 +521,7 @@ t.test( 'got symlink', ) t.ok(fs.lstatSync(cwd + '/d/i/r/dir/x').isFile(), 'x thru link') - t.ok( - fs.lstatSync(cwd + '/d/i/r/symlink/x').isFile(), - 'x thru link', - ) + t.ok(fs.lstatSync(cwd + '/d/i/r/symlink/x').isFile(), 'x thru link') t.end() }) @@ -606,10 +592,7 @@ t.test( fs.lstatSync(cwd + '/d/i/r/symlink').isDirectory(), 'sym is dir', ) - t.ok( - fs.lstatSync(cwd + '/d/i/r/symlink/x').isFile(), - 'x thru link', - ) + t.ok(fs.lstatSync(cwd + '/d/i/r/symlink/x').isFile(), 'x thru link') t.end() }) @@ -950,10 +933,7 @@ t.test('absolute paths', t => { { path: normPath(absolute), code: 'TAR_ENTRY_INFO' }, ], ]) - t.ok( - fs.lstatSync(path.resolve(dir, relative)).isFile(), - 'is file', - ) + t.ok(fs.lstatSync(path.resolve(dir, relative)).isFile(), 'is file') t.end() } @@ -1061,10 +1041,7 @@ t.test('.. paths', t => { t.test('warn and skip', t => { const check = t => { t.match(warnings, [ - [ - "path contains '..'", - { path: dotted, code: 'TAR_ENTRY_ERROR' }, - ], + ["path contains '..'", { path: dotted, code: 'TAR_ENTRY_ERROR' }], ]) t.throws(() => fs.lstatSync(resolved)) t.end() @@ -1909,9 +1886,7 @@ t.test('set owner', t => { t.not(fileStat.gid, 813708013) const dirStat2 = fs.statSync(dir + '/foo/different-uid-nogid') t.not(dirStat2.uid, 2456124561) - const fileStat2 = fs.statSync( - dir + '/foo/different-uid-nogid/bar', - ) + const fileStat2 = fs.statSync(dir + '/foo/different-uid-nogid/bar') t.not(fileStat2.uid, 2456124561) t.end() } @@ -2328,8 +2303,7 @@ t.test('bad cwd setting', t => { .on('error', er => { t.match(er, { name: 'CwdError', - message: - "ENOTDIR: Cannot cd into '" + normPath(cwd) + "'", + message: "ENOTDIR: Cannot cd into '" + normPath(cwd) + "'", path: normPath(cwd), code: 'ENOTDIR', }) @@ -2353,8 +2327,7 @@ t.test('bad cwd setting', t => { .on('error', er => { t.match(er, { name: 'CwdError', - message: - "ENOENT: Cannot cd into '" + normPath(cwd) + "'", + message: "ENOENT: Cannot cd into '" + normPath(cwd) + "'", path: normPath(cwd), code: 'ENOENT', }) @@ -2818,11 +2791,7 @@ t.test('trying to unpack a non-zlib gzip file should fail', t => { new Unpack(opts) .once('error', er => t.match(er, expect, 'async emits')) .end(data) - t.throws( - () => new UnpackSync(opts).end(data), - expect, - 'sync throws', - ) + t.throws(() => new UnpackSync(opts).end(data), expect, 'sync throws') }) t.end() @@ -3200,12 +3169,7 @@ t.test('recognize C:.. as a dot path part', async t => { 'C:../x/y/z', 'C:../x/y/z', ], - [ - 'TAR_ENTRY_ERROR', - "path contains '..'", - 'x:../y/z', - 'x:../y/z', - ], + ['TAR_ENTRY_ERROR', "path contains '..'", 'x:../y/z', 'x:../y/z'], [ 'TAR_ENTRY_INFO', 'stripping Y: from absolute path', @@ -3317,11 +3281,7 @@ t.test('ignore self-referential hardlinks', async t => { ]) const check = (t, warnings) => { t.matchSnapshot(warnings) - t.strictSame( - fs.readdirSync(t.testdirName), - [], - 'nothing extracted', - ) + t.strictSame(fs.readdirSync(t.testdirName), [], 'nothing extracted') t.end() } t.test('async', t => { @@ -3343,90 +3303,84 @@ t.test('ignore self-referential hardlinks', async t => { }) }) -t.test( - 'valid relative symlink with .. should be extracted', - async t => { - const makeTar = () => { - // foo/file.txt (regular file) - // bar/link.txt -> ../foo/file.txt (valid relative symlink) - const chunks = [] - - const fooDirHeader = Buffer.alloc(512) - new Header({ - path: 'foo/', - type: 'Directory', - mode: 0o755, - }).encode(fooDirHeader, 0) - chunks.push(fooDirHeader) - - const fileContent = 'hello world' - const fileHeader = Buffer.alloc(512) - new Header({ - path: 'foo/file.txt', - type: 'File', - mode: 0o644, - size: fileContent.length, - }).encode(fileHeader, 0) - chunks.push(fileHeader) - - const contentBuf = Buffer.alloc(512) - contentBuf.write(fileContent) - chunks.push(contentBuf) - - const barDirHeader = Buffer.alloc(512) - new Header({ - path: 'bar/', - type: 'Directory', - mode: 0o755, - }).encode(barDirHeader, 0) - chunks.push(barDirHeader) +t.test('valid relative symlink with .. should be extracted', async t => { + const makeTar = () => { + // foo/file.txt (regular file) + // bar/link.txt -> ../foo/file.txt (valid relative symlink) + const chunks = [] - const symlinkHeader = Buffer.alloc(512) - new Header({ - path: 'bar/link.txt', - type: 'SymbolicLink', - linkpath: '../foo/file.txt', - }).encode(symlinkHeader, 0) - chunks.push(symlinkHeader) + const fooDirHeader = Buffer.alloc(512) + new Header({ + path: 'foo/', + type: 'Directory', + mode: 0o755, + }).encode(fooDirHeader, 0) + chunks.push(fooDirHeader) + + const fileContent = 'hello world' + const fileHeader = Buffer.alloc(512) + new Header({ + path: 'foo/file.txt', + type: 'File', + mode: 0o644, + size: fileContent.length, + }).encode(fileHeader, 0) + chunks.push(fileHeader) - const escapedSymlinkHeader = Buffer.alloc(512) - new Header({ - path: 'bar/badlink.txt', - type: 'SymbolicLink', - linkpath: '../../oh/no', - }).encode(escapedSymlinkHeader) - chunks.push(escapedSymlinkHeader) + const contentBuf = Buffer.alloc(512) + contentBuf.write(fileContent) + chunks.push(contentBuf) - chunks.push(Buffer.alloc(1024)) + const barDirHeader = Buffer.alloc(512) + new Header({ + path: 'bar/', + type: 'Directory', + mode: 0o755, + }).encode(barDirHeader, 0) + chunks.push(barDirHeader) - return Buffer.concat(chunks) - } + const symlinkHeader = Buffer.alloc(512) + new Header({ + path: 'bar/link.txt', + type: 'SymbolicLink', + linkpath: '../foo/file.txt', + }).encode(symlinkHeader, 0) + chunks.push(symlinkHeader) - const dir = t.testdir({ - 'test.tar': makeTar(), - }) + const escapedSymlinkHeader = Buffer.alloc(512) + new Header({ + path: 'bar/badlink.txt', + type: 'SymbolicLink', + linkpath: '../../oh/no', + }).encode(escapedSymlinkHeader) + chunks.push(escapedSymlinkHeader) - const warnings = [] + chunks.push(Buffer.alloc(1024)) - await extract({ - cwd: dir, - file: dir + '/test.tar', - onwarn: (c, m) => warnings.push([c, m]), - }) + return Buffer.concat(chunks) + } - t.ok(fs.lstatSync(dir + '/foo/file.txt').isFile()) - t.ok(fs.lstatSync(dir + '/bar/link.txt').isSymbolicLink()) - t.equal(fs.readlinkSync(dir + '/bar/link.txt'), '../foo/file.txt') - t.equal( - fs.readFileSync(dir + '/bar/link.txt', 'utf8'), - 'hello world', - ) - t.throws(() => fs.statSync(dir + '/bar/badlink.txt')) - t.match(warnings, [ - ['TAR_ENTRY_ERROR', 'linkpath escapes extraction directory'], - ]) - }, -) + const dir = t.testdir({ + 'test.tar': makeTar(), + }) + + const warnings = [] + + await extract({ + cwd: dir, + file: dir + '/test.tar', + onwarn: (c, m) => warnings.push([c, m]), + }) + + t.ok(fs.lstatSync(dir + '/foo/file.txt').isFile()) + t.ok(fs.lstatSync(dir + '/bar/link.txt').isSymbolicLink()) + t.equal(fs.readlinkSync(dir + '/bar/link.txt'), '../foo/file.txt') + t.equal(fs.readFileSync(dir + '/bar/link.txt', 'utf8'), 'hello world') + t.throws(() => fs.statSync(dir + '/bar/badlink.txt')) + t.match(warnings, [ + ['TAR_ENTRY_ERROR', 'linkpath escapes extraction directory'], + ]) +}) t.test('no linking through a symlink', t => { const types = ['Link', 'SymbolicLink'] diff --git a/test/update.js b/test/update.js index f00d59c7..9bf6062f 100644 --- a/test/update.js +++ b/test/update.js @@ -42,10 +42,7 @@ t.test('basic file add to archive (good or truncated)', t => { c.on('close', (code, signal) => { t.equal(code, 0) t.equal(signal, null) - const actual = Buffer.concat(out) - .toString() - .trim() - .split(/\r?\n/) + const actual = Buffer.concat(out).toString().trim().split(/\r?\n/) t.same(actual, [ '1024-bytes.txt', '512-bytes.txt', @@ -139,10 +136,7 @@ t.test('add to empty archive', t => { c.on('close', (code, signal) => { t.equal(code, 0) t.equal(signal, null) - const actual = Buffer.concat(out) - .toString() - .trim() - .split(/\r?\n/) + const actual = Buffer.concat(out).toString().trim().split(/\r?\n/) t.same(actual, [path.basename(__filename)]) t.end() }) @@ -225,9 +219,7 @@ t.test('cannot append to gzipped archives', t => { const file = resolve(dir, 'compressed.tgz') const expect = new Error('cannot append to compressed archives') - const expectT = new TypeError( - 'cannot append to compressed archives', - ) + const expectT = new TypeError('cannot append to compressed archives') t.throws( _ => @@ -275,9 +267,7 @@ t.test('cannot append to brotli archives', t => { const file = resolve(dir, 'compressed.tbr') const expect = new Error('cannot append to compressed archives') - const expectT = new TypeError( - 'cannot append to compressed archives', - ) + const expectT = new TypeError('cannot append to compressed archives') t.throws( _ => @@ -315,9 +305,7 @@ t.test('cannot append to zstd archives', t => { const file = resolve(dir, 'compressed.tzst') const expect = new Error('cannot append to compressed archives') - const expectT = new TypeError( - 'cannot append to compressed archives', - ) + const expectT = new TypeError('cannot append to compressed archives') t.throws( _ => @@ -460,8 +448,7 @@ t.test('do add newer file', t => { } // a chunk for the header, then 2 for the body - const expect = - fixtureDef['body-byte-counts.tar'].length + 512 + 1024 + const expect = fixtureDef['body-byte-counts.tar'].length + 512 + 1024 const check = (file, t) => { t.equal(fs.statSync(file).size, expect) t.end() @@ -486,9 +473,7 @@ t.test('do add newer file', t => { t.test('async', t => { const dir = setup(t) const file = resolve(dir, 'body-byte-counts.tar') - u({ file, cwd: dir }, ['1024-bytes.txt']).then(_ => - check(file, t), - ) + u({ file, cwd: dir }, ['1024-bytes.txt']).then(_ => check(file, t)) }) t.test('async cb', t => { diff --git a/test/write-entry.js b/test/write-entry.js index d173e526..afd0a063 100644 --- a/test/write-entry.js +++ b/test/write-entry.js @@ -322,9 +322,7 @@ t.test('hardlinks far away', t => { const h1 = 'hardlink-1' const f = path.resolve(files, h1) const stat = fs.statSync(f) - const linkCache = new Map([ - [stat.dev + ':' + stat.ino, '/a/b/c/d/e'], - ]) + const linkCache = new Map([[stat.dev + ':' + stat.ino, '/a/b/c/d/e']]) const ws = new WriteEntry('files/hardlink-2', { cwd: fixtures, @@ -581,29 +579,22 @@ t.test('readlink fail', t => { t.throws(_ => { return new WriteEntrySync('write-entry.js', { cwd: __dirname }) }, expect) - new WriteEntry('write-entry.js', { cwd: __dirname }).on( - 'error', - er => { - t.match(er, expect) - t.equal(normPath(er.path), normPath(__filename)) - t.end() - }, - ) + new WriteEntry('write-entry.js', { cwd: __dirname }).on('error', er => { + t.match(er, expect) + t.equal(normPath(er.path), normPath(__filename)) + t.end() + }) }) t.test('open fail', t => { t.teardown(mutateFS.fail('open', new Error('pwn'))) - t.throws( - _ => new WriteEntrySync('write-entry.js', { cwd: __dirname }), - { message: 'pwn' }, - ) - new WriteEntry('write-entry.js', { cwd: __dirname }).on( - 'error', - er => { - t.match(er, { message: 'pwn' }) - t.end() - }, - ) + t.throws(_ => new WriteEntrySync('write-entry.js', { cwd: __dirname }), { + message: 'pwn', + }) + new WriteEntry('write-entry.js', { cwd: __dirname }).on('error', er => { + t.match(er, { message: 'pwn' }) + t.end() + }) }) t.test('read fail', t => { @@ -647,13 +638,10 @@ t.test('read invalid EOF', t => { _ => new WriteEntrySync('write-entry.js', { cwd: __dirname }), expect, ) - new WriteEntry('write-entry.js', { cwd: __dirname }).on( - 'error', - er => { - t.match(er, expect) - t.end() - }, - ) + new WriteEntry('write-entry.js', { cwd: __dirname }).on('error', er => { + t.match(er, expect) + t.end() + }) }) t.test('read overflow expectation', t => { @@ -706,10 +694,7 @@ t.test('short reads', t => { ws.on('data', c => out.push(c)) ws.on('end', _ => { out = Buffer.concat(out) - t.equal( - out.length, - 512 * Math.ceil(1 + contents.length / 512), - ) + t.equal(out.length, 512 * Math.ceil(1 + contents.length / 512)) t.equal( out.slice(512).toString().replace(/\0.*$/, ''), contents, @@ -749,8 +734,7 @@ t.test( t.test( 'win32 <|>? in paths', { - skip: - isWindows && 'do not create annoying junk on windows systems', + skip: isWindows && 'do not create annoying junk on windows systems', }, t => { const file = path.resolve(fixtures, '<|>?.txt') @@ -1367,10 +1351,7 @@ t.test('prefix and hard links', t => { const data = Buffer.concat(out) expect.forEach((e, i) => { if (typeof e === 'string') { - t.equal( - data.subarray(i * 512, i * 512 + e.length).toString(), - e, - ) + t.equal(data.subarray(i * 512, i * 512 + e.length).toString(), e) } else if (e instanceof RegExp) { t.match(data.subarray(i * 512, (i + 1) * 512).toString(), e) } else { @@ -1547,10 +1528,7 @@ t.test('prefix and hard links from tar entries', t => { const data = Buffer.concat(out) expect.forEach((e, i) => { if (typeof e === 'string') { - t.equal( - data.subarray(i * 512, i * 512 + e.length).toString(), - e, - ) + t.equal(data.subarray(i * 512, i * 512 + e.length).toString(), e) } else if (e instanceof RegExp) { t.match(data.subarray(i * 512, (i + 1) * 512).toString(), e) } else { @@ -1645,10 +1623,7 @@ t.test('hard links and no prefix', t => { const data = Buffer.concat(out) expect.forEach((e, i) => { if (typeof e === 'string') { - t.equal( - data.subarray(i * 512, i * 512 + e.length).toString(), - e, - ) + t.equal(data.subarray(i * 512, i * 512 + e.length).toString(), e) } else { t.match(new Header(data.subarray(i * 512, (i + 1) * 512)), e) } @@ -1794,10 +1769,7 @@ t.test('hard links from tar entries and no prefix', t => { const data = Buffer.concat(out) expect.forEach((e, i) => { if (typeof e === 'string') { - t.equal( - data.subarray(i * 512, i * 512 + e.length).toString(), - e, - ) + t.equal(data.subarray(i * 512, i * 512 + e.length).toString(), e) } else if (e instanceof RegExp) { t.match(data.subarray(i * 512, (i + 1) * 512).toString(), e) } else {