|
7 | 7 | * it. |
8 | 8 | */ |
9 | 9 |
|
10 | | -import { stat, readFile } from 'node:fs/promises'; |
11 | | -import { createWriteStream } from 'node:fs'; |
12 | | -import { PassThrough } from 'node:stream'; |
13 | | -import cliProgress from 'cli-progress'; |
14 | | -import unzipper from 'unzipper'; |
15 | | -import os from 'node:os'; |
16 | | -import { mkdirp } from 'mkdirp'; |
17 | | -import { resolve } from 'node:path'; |
18 | | -import { exec } from 'node:child_process'; |
19 | | -import { promisify } from 'node:util'; |
20 | | -import fetch from 'node-fetch'; |
21 | | -import prettyBytes from 'pretty-bytes'; |
22 | | -import { packageDirectory } from 'pkg-dir'; |
| 10 | +const { stat, readFile } = require('node:fs/promises'); |
| 11 | +const { createWriteStream } = require('node:fs'); |
| 12 | +const { PassThrough } = require('node:stream'); |
| 13 | +const cliProgress = require('cli-progress'); |
| 14 | +const unzipper = require('unzipper'); |
| 15 | +const os = require('node:os'); |
| 16 | +const { mkdirp } = require('mkdirp'); |
| 17 | +const { resolve } = require('node:path'); |
| 18 | +const { exec } = require('node:child_process'); |
| 19 | +const { promisify } = require('node:util'); |
| 20 | +// node-fetch v3 is ES module only, so we'll import it dynamically |
| 21 | +// pretty-bytes is ES module only, so we'll import it dynamically |
| 22 | +// pkg-dir is ES module only, so we'll import it dynamically |
23 | 23 |
|
24 | 24 | const pExec = promisify(exec); |
25 | 25 |
|
@@ -72,6 +72,8 @@ function getPlatform() { |
72 | 72 |
|
73 | 73 | async function downloadFromUrl(appRoot, url) { |
74 | 74 | console.log(`Checking for a release at: ${url}`); |
| 75 | + const { default: fetch } = await import('node-fetch'); |
| 76 | + const { default: prettyBytes } = await import('pretty-bytes'); |
75 | 77 | const res = await fetch(url); |
76 | 78 |
|
77 | 79 | if (res.ok) { |
@@ -171,7 +173,8 @@ async function buildRust(root) { |
171 | 173 | } |
172 | 174 |
|
173 | 175 | async function main() { |
174 | | - const appRoot = await packageDirectory(import.meta.url); |
| 176 | + const { packageDirectory } = await import('pkg-dir'); |
| 177 | + const appRoot = await packageDirectory(__filename); |
175 | 178 | const distRoot = resolve(appRoot, 'dist'); |
176 | 179 | const cargoDistPath = resolve(distRoot, 'Cargo.toml'); |
177 | 180 | const libraryOverridePath = process.env.C2PA_LIBRARY_PATH; |
|
0 commit comments