From: Chris Duncan Date: Sat, 22 Mar 2025 06:44:07 +0000 (-0700) Subject: Fix cli file paths for older versions of Node. X-Git-Tag: v4.0.4~1 X-Git-Url: https://zoso.dev/?a=commitdiff_plain;h=6c61a81cbd9e32c84d7a744efde0925fe162a846;p=nano-pow.git Fix cli file paths for older versions of Node. --- diff --git a/src/bin/cli.ts b/src/bin/cli.ts index 2a3c135..9d0f518 100755 --- a/src/bin/cli.ts +++ b/src/bin/cli.ts @@ -2,7 +2,7 @@ //! SPDX-FileCopyrightText: 2025 Chris Duncan //! SPDX-License-Identifier: GPL-3.0-or-later /// - +import * as crypto from 'node:crypto' import * as fs from 'node:fs/promises' import * as readline from 'node:readline/promises' import * as puppeteer from 'puppeteer' @@ -107,8 +107,9 @@ if (hashes.length === 0) { ] }) const page = await browser.newPage() - const cliPage = `${import.meta.dirname}/cli.html` - await fs.writeFile(cliPage, '') + const path: string = new URL(import.meta.url).pathname + const dir = path.slice(0, path.lastIndexOf('/')) + await fs.writeFile(`${dir}/cli.html`, '') await page.goto(import.meta.resolve('./cli.html')) await page.waitForFunction(async (): Promise => { return await navigator.gpu.requestAdapter() @@ -170,6 +171,6 @@ if (hashes.length === 0) { `) - await fs.unlink(cliPage) + await fs.unlink(`${dir}/cli.html`) if (options['debug']) console.log('Puppeteer initialized') })()