From 6c61a81cbd9e32c84d7a744efde0925fe162a846 Mon Sep 17 00:00:00 2001 From: Chris Duncan Date: Fri, 21 Mar 2025 23:44:07 -0700 Subject: [PATCH] Fix cli file paths for older versions of Node. --- src/bin/cli.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) 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') })() -- 2.34.1