]> zoso.dev Git - nano-pow.git/commitdiff
Fix cli file paths for older versions of Node.
authorChris Duncan <chris@zoso.dev>
Sat, 22 Mar 2025 06:44:07 +0000 (23:44 -0700)
committerChris Duncan <chris@zoso.dev>
Sat, 22 Mar 2025 06:44:07 +0000 (23:44 -0700)
src/bin/cli.ts

index 2a3c135ad711bf6a91cce1a3212f30ced9559cb0..9d0f518a117a8e09295fb988db659c8269a8eac2 100755 (executable)
@@ -2,7 +2,7 @@
 //! SPDX-FileCopyrightText: 2025 Chris Duncan <chris@zoso.dev>
 //! SPDX-License-Identifier: GPL-3.0-or-later
 /// <reference types="@webgpu/types" />
-
+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<GPUAdapter | null> => {
                return await navigator.gpu.requestAdapter()
@@ -170,6 +171,6 @@ if (hashes.length === 0) {
                        </head>
                </html>
        `)
-       await fs.unlink(cliPage)
+       await fs.unlink(`${dir}/cli.html`)
        if (options['debug']) console.log('Puppeteer initialized')
 })()