Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@ module.exports = {
ecmaVersion: 2025,
sourceType: 'module',
},
plugins: ['mocha', '@typescript-eslint'],
plugins: ['@typescript-eslint'],
env: {
es6: true,
mocha: true,
node: true,
},
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended'],
rules: {
'mocha/no-exclusive-tests': 'error',
'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': [
'error',
Expand Down
10 changes: 0 additions & 10 deletions .mocharc.jsonc

This file was deleted.

25 changes: 7 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
"scripts": {
"build": "tsc",
"build:docs": "typedoc src/main.ts",
"coverage": "npm run prewarm-headers && nyc npm run spec",
"coverage:report": "nyc report --reporter=text-lcov > coverage.lcov",
"coverage": "npm run prewarm-headers && vitest run --coverage",
"coverage:report": "vitest run --coverage --coverage.reporter=lcov",
"watch": "tsc -w",
"prepare": "npm run build",
"lint": "eslint --ext .ts .",
"spec": "tsc && mocha",
"test": "npm run prewarm-headers && npm run lint && npm run spec",
"pretest": "npm run prewarm-headers && npm run lint && tsc",
"test": "vitest run",
"prewarm-headers": "node-gyp install --ensure"
},
"bin": {
Expand Down Expand Up @@ -62,32 +62,21 @@
"yargs": "^17.0.1"
},
"devDependencies": {
"@istanbuljs/nyc-config-typescript": "^1.0.1",
"@tsconfig/node22": "^22.0.0",
"@types/chai": "^4.2.12",
"@types/chai-as-promised": "^7.1.3",
"@types/debug": "^4.1.5",
"@types/graceful-fs": "^4.1.9",
"@types/mocha": "^10.0.10",
"@types/node": "~22.10.7",
"@types/node-abi": "^3.0.0",
"@types/semver": "^7.3.9",
"@types/tar": "^6.1.0",
"@types/yargs": "^17.0.2",
"@typescript-eslint/eslint-plugin": "^6.21.0",
"@typescript-eslint/parser": "^6.21.0",
"chai": "^4.2.0",
"chai-as-promised": "^7.1.1",
"@vitest/coverage-v8": "^3.1.2",
"electron": "^22.0.0",
"eslint": "^7.7.0",
"eslint-plugin-mocha": "^9.0.0",
"mocha": "^11.1.0",
"nyc": "^15.1.0",
"tsx": "^4.19.3",
"typedoc": "~0.25.13",
"typescript": "~5.4.5"
},
"nyc": {
"extends": "@istanbuljs/nyc-config-typescript"
"typescript": "~5.4.5",
"vitest": "^3.1.2"
}
}
3 changes: 2 additions & 1 deletion src/electron-locator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ async function locateModuleByImport(): Promise<string | null> {
if (fs.existsSync(path.join(modulePath, 'package.json'))) {
return modulePath;
}
} catch { // eslint-disable-line no-empty
} catch (err) { // eslint-disable-line no-empty
console.log(err);
}
}

Expand Down
2 changes: 1 addition & 1 deletion test/arch.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect } from 'chai';
import { describe, expect, it } from 'vitest';

import { getNodeArch, uname } from '../lib/arch.js';

Check failure on line 3 in test/arch.ts

View workflow job for this annotation

GitHub Actions / Test (22.12.x, macos-latest)

test/arch.ts

Error: Cannot find module '../lib/arch.js' imported from '/Users/runner/work/rebuild/rebuild/test/arch.ts' ❯ test/arch.ts:3:1 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { code: 'ERR_MODULE_NOT_FOUND' } Caused by: Caused by: Error: Failed to load url ../lib/arch.js (resolved id: ../lib/arch.js) in /Users/runner/work/rebuild/rebuild/test/arch.ts. Does the file exist? ❯ loadAndTransform node_modules/vite/dist/node/chunks/dep-Bn81Esdm.js:35725:17

Check failure on line 3 in test/arch.ts

View workflow job for this annotation

GitHub Actions / Test (22.12.x, ubuntu-latest)

test/arch.ts

Error: Cannot find module '../lib/arch.js' imported from '/home/runner/work/rebuild/rebuild/test/arch.ts' ❯ test/arch.ts:3:1 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { code: 'ERR_MODULE_NOT_FOUND' } Caused by: Caused by: Error: Failed to load url ../lib/arch.js (resolved id: ../lib/arch.js) in /home/runner/work/rebuild/rebuild/test/arch.ts. Does the file exist? ❯ loadAndTransform node_modules/vite/dist/node/chunks/dep-Bn81Esdm.js:35725:17

// Copied from @electron/get
describe('uname()', () => {
Expand Down
6 changes: 3 additions & 3 deletions test/electron-locator.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { expect } from 'chai';
import fs from 'graceful-fs';
import path from 'node:path';
import { afterAll, beforeAll, describe, expect, it } from 'vitest';

import { locateElectronModule } from '../lib/electron-locator.js';

Check failure on line 5 in test/electron-locator.ts

View workflow job for this annotation

GitHub Actions / Test (22.12.x, macos-latest)

test/electron-locator.ts

Error: Cannot find module '../lib/electron-locator.js' imported from '/Users/runner/work/rebuild/rebuild/test/electron-locator.ts' ❯ test/electron-locator.ts:5:1 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { code: 'ERR_MODULE_NOT_FOUND' } Caused by: Caused by: Error: Failed to load url ../lib/electron-locator.js (resolved id: ../lib/electron-locator.js) in /Users/runner/work/rebuild/rebuild/test/electron-locator.ts. Does the file exist? ❯ loadAndTransform node_modules/vite/dist/node/chunks/dep-Bn81Esdm.js:35725:17

Check failure on line 5 in test/electron-locator.ts

View workflow job for this annotation

GitHub Actions / Test (22.12.x, ubuntu-latest)

test/electron-locator.ts

Error: Cannot find module '../lib/electron-locator.js' imported from '/home/runner/work/rebuild/rebuild/test/electron-locator.ts' ❯ test/electron-locator.ts:5:1 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { code: 'ERR_MODULE_NOT_FOUND' } Caused by: Caused by: Error: Failed to load url ../lib/electron-locator.js (resolved id: ../lib/electron-locator.js) in /home/runner/work/rebuild/rebuild/test/electron-locator.ts. Does the file exist? ❯ loadAndTransform node_modules/vite/dist/node/chunks/dep-Bn81Esdm.js:35725:17

const baseFixtureDir = path.resolve(import.meta.dirname, 'fixture', 'electron-locator');

Expand All @@ -19,7 +19,7 @@
describe('when electron is not installed', () => {
const electronDir = path.resolve(import.meta.dirname, '..', 'node_modules', 'electron');

before(async () => {
beforeAll(async () => {
await fs.promises.rename(electronDir, `${electronDir}-moved`);
});

Expand All @@ -28,7 +28,7 @@
expect(await locateElectronModule(fixtureDir, fixtureDir)).to.be.equal(null);
});

after(async () => {
afterAll(async () => {
await fs.promises.rename(`${electronDir}-moved`, electronDir);
});
});
Expand Down
7 changes: 0 additions & 7 deletions test/helpers/module-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,6 @@ export function resetMSVSVersion(): void {
const testModuleTmpPath = fs.mkdtempSync(path.resolve(os.tmpdir(), 'e-r-test-module-'));

export async function resetTestModule(testModulePath: string, installModules = true, fixtureName = 'native-app1'): Promise<void> {
/**
* Remove the `--import` CLI flag added by Mocha so Node doesn't try to load
* `tsx` when we spawn the `node-gyp` worker, which would fail because the
* test fixtures don't include that dependency.
*/
process.execArgv = process.execArgv.filter(item => item !== '--import=tsx');

const oneTimeModulePath = path.resolve(testModuleTmpPath, `${crypto.createHash('SHA1').update(testModulePath).digest('hex')}-${fixtureName}-${installModules}`);
if (!fs.existsSync(oneTimeModulePath)) {
d(`creating test module '%s' in %s`, fixtureName, oneTimeModulePath);
Expand Down
2 changes: 1 addition & 1 deletion test/helpers/rebuild.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect } from 'chai';
import fs from 'graceful-fs';
import path from 'node:path';
import { expect } from 'vitest';

type ExpectRebuildOptions = {
buildType?: string;
Expand Down
19 changes: 8 additions & 11 deletions test/module-type-node-gyp.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
import { EventEmitter } from 'node:events';
import chai, { expect } from 'chai';
import chaiAsPromised from 'chai-as-promised';
import { afterAll, beforeAll, describe, expect, it } from 'vitest';

import { cleanupTestModule, resetTestModule, TEST_MODULE_PATH as testModulePath } from './helpers/module-setup.js';
import { NodeGyp } from '../lib/module-type/node-gyp/node-gyp.js';

Check failure on line 5 in test/module-type-node-gyp.ts

View workflow job for this annotation

GitHub Actions / Test (22.12.x, macos-latest)

test/module-type-node-gyp.ts

Error: Cannot find module '../lib/module-type/node-gyp/node-gyp.js' imported from '/Users/runner/work/rebuild/rebuild/test/module-type-node-gyp.ts' ❯ test/module-type-node-gyp.ts:5:1 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { code: 'ERR_MODULE_NOT_FOUND' } Caused by: Caused by: Error: Failed to load url ../lib/module-type/node-gyp/node-gyp.js (resolved id: ../lib/module-type/node-gyp/node-gyp.js) in /Users/runner/work/rebuild/rebuild/test/module-type-node-gyp.ts. Does the file exist? ❯ loadAndTransform node_modules/vite/dist/node/chunks/dep-Bn81Esdm.js:35725:17

Check failure on line 5 in test/module-type-node-gyp.ts

View workflow job for this annotation

GitHub Actions / Test (22.12.x, ubuntu-latest)

test/module-type-node-gyp.ts

Error: Cannot find module '../lib/module-type/node-gyp/node-gyp.js' imported from '/home/runner/work/rebuild/rebuild/test/module-type-node-gyp.ts' ❯ test/module-type-node-gyp.ts:5:1 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { code: 'ERR_MODULE_NOT_FOUND' } Caused by: Caused by: Error: Failed to load url ../lib/module-type/node-gyp/node-gyp.js (resolved id: ../lib/module-type/node-gyp/node-gyp.js) in /home/runner/work/rebuild/rebuild/test/module-type-node-gyp.ts. Does the file exist? ❯ loadAndTransform node_modules/vite/dist/node/chunks/dep-Bn81Esdm.js:35725:17
import { Rebuilder } from '../lib/rebuild.js';

chai.use(chaiAsPromised);

describe('node-gyp', () => {
describe('buildArgs', () => {

before(async () => await resetTestModule(testModulePath, false));
after(async () => await cleanupTestModule(testModulePath));
beforeAll(async () => await resetTestModule(testModulePath, false), 30_000);
afterAll(async () => await cleanupTestModule(testModulePath), 30_000);

function nodeGypArgsForElectronVersion(electronVersion: string): Promise<string[]> {
const rebuilder = new Rebuilder({
Expand All @@ -24,7 +21,7 @@
return nodeGyp.buildArgs([]);
}

context('sufficiently old Electron versions which lack a bundled config.gypi', () => {
describe('sufficiently old Electron versions which lack a bundled config.gypi', () => {
it('adds --force-process-config for < 14', async () => {
const args = await nodeGypArgsForElectronVersion('12.0.0');
expect(args).to.include('--force-process-config');
Expand All @@ -41,7 +38,7 @@
});
});

context('for sufficiently new Electron versions', () => {
describe('for sufficiently new Electron versions', () => {
it('does not add --force-process-config for ^14.2.0', async () => {
const args = await nodeGypArgsForElectronVersion('14.2.0');
expect(args).to.not.include('--force-process-config');
Expand All @@ -58,8 +55,8 @@
});
});

context('cross-compilation', async () => {
it('throws error early if platform mismatch', async function () {
describe('cross-compilation', async () => {
it('throws error early if platform mismatch', async () => {
let platform: NodeJS.Platform = 'darwin';

// we're verifying platform mismatch error throwing, not `rebuildModule` rebuilding.
Expand All @@ -76,7 +73,7 @@
const nodeGyp = new NodeGyp(rebuilder, testModulePath);

const errorMessage = "node-gyp does not support cross-compiling native modules from source.";
expect(nodeGyp.rebuildModule()).to.eventually.be.rejectedWith(new Error(errorMessage));
await expect(nodeGyp.rebuildModule()).rejects.toThrow(new Error(errorMessage));
});
});
});
Expand Down
17 changes: 6 additions & 11 deletions test/module-type-node-pre-gyp.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
import chai, { expect } from 'chai';
import chaiAsPromised from 'chai-as-promised';
import { EventEmitter } from 'node:events';
import path from 'node:path';
import { afterAll, beforeAll, describe, expect, it } from 'vitest';

import { cleanupTestModule, resetTestModule, TIMEOUT_IN_MILLISECONDS, TEST_MODULE_PATH as testModulePath } from './helpers/module-setup.js';
import { NodePreGyp } from '../lib/module-type/node-pre-gyp.js';

Check failure on line 6 in test/module-type-node-pre-gyp.ts

View workflow job for this annotation

GitHub Actions / Test (22.12.x, macos-latest)

test/module-type-node-pre-gyp.ts

Error: Cannot find module '../lib/module-type/node-pre-gyp.js' imported from '/Users/runner/work/rebuild/rebuild/test/module-type-node-pre-gyp.ts' ❯ test/module-type-node-pre-gyp.ts:6:1 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { code: 'ERR_MODULE_NOT_FOUND' } Caused by: Caused by: Error: Failed to load url ../lib/module-type/node-pre-gyp.js (resolved id: ../lib/module-type/node-pre-gyp.js) in /Users/runner/work/rebuild/rebuild/test/module-type-node-pre-gyp.ts. Does the file exist? ❯ loadAndTransform node_modules/vite/dist/node/chunks/dep-Bn81Esdm.js:35725:17

Check failure on line 6 in test/module-type-node-pre-gyp.ts

View workflow job for this annotation

GitHub Actions / Test (22.12.x, ubuntu-latest)

test/module-type-node-pre-gyp.ts

Error: Cannot find module '../lib/module-type/node-pre-gyp.js' imported from '/home/runner/work/rebuild/rebuild/test/module-type-node-pre-gyp.ts' ❯ test/module-type-node-pre-gyp.ts:6:1 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { code: 'ERR_MODULE_NOT_FOUND' } Caused by: Caused by: Error: Failed to load url ../lib/module-type/node-pre-gyp.js (resolved id: ../lib/module-type/node-pre-gyp.js) in /home/runner/work/rebuild/rebuild/test/module-type-node-pre-gyp.ts. Does the file exist? ❯ loadAndTransform node_modules/vite/dist/node/chunks/dep-Bn81Esdm.js:35725:17
import { Rebuilder, RebuilderOptions } from '../lib/rebuild.js';

chai.use(chaiAsPromised);

describe('node-pre-gyp', function () {
this.timeout(TIMEOUT_IN_MILLISECONDS);

describe('node-pre-gyp', { timeout: TIMEOUT_IN_MILLISECONDS }, () => {
const modulePath = path.join(testModulePath, 'node_modules', 'sqlite3');
const rebuilderArgs: RebuilderOptions = {
buildPath: testModulePath,
Expand All @@ -20,10 +15,10 @@
lifecycle: new EventEmitter()
};

before(async () => await resetTestModule(testModulePath));
after(async () => await cleanupTestModule(testModulePath));
beforeAll(async () => await resetTestModule(testModulePath), TIMEOUT_IN_MILLISECONDS);
afterAll(async () => await cleanupTestModule(testModulePath), TIMEOUT_IN_MILLISECONDS);

describe('Node-API support', function() {
describe('Node-API support', () => {
it('should find correct napi version and select napi args', async () => {
const rebuilder = new Rebuilder(rebuilderArgs);
const nodePreGyp = new NodePreGyp(rebuilder, modulePath);
Expand All @@ -44,7 +39,7 @@
electronVersion: '2.0.0',
});
const nodePreGyp = new NodePreGyp(rebuilder, modulePath);
expect(nodePreGyp.findPrebuiltModule()).to.eventually.be.rejectedWith("Native module 'sqlite3' requires Node-API but Electron v2.0.0 does not support Node-API");
await expect(nodePreGyp.findPrebuiltModule()).rejects.toBe("Native module 'sqlite3' requires Node-API but Electron v2.0.0 does not support Node-API");
});
});

Expand Down
19 changes: 7 additions & 12 deletions test/module-type-prebuild-install.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import chai, { expect } from 'chai';
import chaiAsPromised from 'chai-as-promised';
import { EventEmitter } from 'node:events';
import path from 'node:path';
import { afterAll, beforeAll, describe, expect, it } from 'vitest';

import { cleanupTestModule, resetTestModule, TIMEOUT_IN_MILLISECONDS, TEST_MODULE_PATH as testModulePath } from './helpers/module-setup.js';
import { PrebuildInstall } from '../lib/module-type/prebuild-install.js';

Check failure on line 6 in test/module-type-prebuild-install.ts

View workflow job for this annotation

GitHub Actions / Test (22.12.x, macos-latest)

test/module-type-prebuild-install.ts

Error: Cannot find module '../lib/module-type/prebuild-install.js' imported from '/Users/runner/work/rebuild/rebuild/test/module-type-prebuild-install.ts' ❯ test/module-type-prebuild-install.ts:6:1 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { code: 'ERR_MODULE_NOT_FOUND' } Caused by: Caused by: Error: Failed to load url ../lib/module-type/prebuild-install.js (resolved id: ../lib/module-type/prebuild-install.js) in /Users/runner/work/rebuild/rebuild/test/module-type-prebuild-install.ts. Does the file exist? ❯ loadAndTransform node_modules/vite/dist/node/chunks/dep-Bn81Esdm.js:35725:17

Check failure on line 6 in test/module-type-prebuild-install.ts

View workflow job for this annotation

GitHub Actions / Test (22.12.x, ubuntu-latest)

test/module-type-prebuild-install.ts

Error: Cannot find module '../lib/module-type/prebuild-install.js' imported from '/home/runner/work/rebuild/rebuild/test/module-type-prebuild-install.ts' ❯ test/module-type-prebuild-install.ts:6:1 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { code: 'ERR_MODULE_NOT_FOUND' } Caused by: Caused by: Error: Failed to load url ../lib/module-type/prebuild-install.js (resolved id: ../lib/module-type/prebuild-install.js) in /home/runner/work/rebuild/rebuild/test/module-type-prebuild-install.ts. Does the file exist? ❯ loadAndTransform node_modules/vite/dist/node/chunks/dep-Bn81Esdm.js:35725:17
import { Rebuilder, RebuilderOptions } from '../lib/rebuild.js';

chai.use(chaiAsPromised);

describe('prebuild-install', () => {
const modulePath = path.join(testModulePath, 'node_modules', 'farmhash');
const rebuilderArgs: RebuilderOptions = {
Expand All @@ -18,11 +15,9 @@
lifecycle: new EventEmitter()
};

describe('Node-API support', function() {
this.timeout(TIMEOUT_IN_MILLISECONDS);

before(async () => await resetTestModule(testModulePath));
after(async () => await cleanupTestModule(testModulePath));
describe('Node-API support', { timeout: TIMEOUT_IN_MILLISECONDS }, () => {
beforeAll(async () => await resetTestModule(testModulePath), 30_000);
afterAll(async () => await cleanupTestModule(testModulePath), 30_000);

it('should find correct napi version and select napi args', async () => {
const rebuilder = new Rebuilder(rebuilderArgs);
Expand All @@ -35,7 +30,7 @@
]);
});

it('should not fail running prebuild-install', async function () {
it('should not fail running prebuild-install', async () => {
const rebuilder = new Rebuilder(rebuilderArgs);
const prebuildInstall = new PrebuildInstall(rebuilder, modulePath);
expect(await prebuildInstall.findPrebuiltModule()).to.equal(true);
Expand All @@ -47,10 +42,10 @@
electronVersion: '2.0.0',
});
const prebuildInstall = new PrebuildInstall(rebuilder, modulePath);
expect(prebuildInstall.findPrebuiltModule()).to.eventually.be.rejectedWith("Native module 'farmhash' requires Node-API but Electron v2.0.0 does not support Node-API");
expect(prebuildInstall.findPrebuiltModule()).rejects.toThrow("Native module 'farmhash' requires Node-API but Electron v2.0.0 does not support Node-API");
});

it('should download for target platform', async function () {
it('should download for target platform', async () => {
let rebuilder = new Rebuilder(rebuilderArgs);
let prebuild = new PrebuildInstall(rebuilder, modulePath);
expect(await prebuild.findPrebuiltModule()).to.equal(true);
Expand Down
2 changes: 1 addition & 1 deletion test/module-type-prebuildify.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { EventEmitter } from 'node:events';
import { expect } from 'chai';
import path from 'node:path';
import { describe, expect, it } from 'vitest';

import {

Check failure on line 5 in test/module-type-prebuildify.ts

View workflow job for this annotation

GitHub Actions / Test (22.12.x, macos-latest)

test/module-type-prebuildify.ts

Error: Cannot find module '../lib/module-type/prebuildify.js' imported from '/Users/runner/work/rebuild/rebuild/test/module-type-prebuildify.ts' ❯ test/module-type-prebuildify.ts:5:1 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { code: 'ERR_MODULE_NOT_FOUND' } Caused by: Caused by: Error: Failed to load url ../lib/module-type/prebuildify.js (resolved id: ../lib/module-type/prebuildify.js) in /Users/runner/work/rebuild/rebuild/test/module-type-prebuildify.ts. Does the file exist? ❯ loadAndTransform node_modules/vite/dist/node/chunks/dep-Bn81Esdm.js:35725:17

Check failure on line 5 in test/module-type-prebuildify.ts

View workflow job for this annotation

GitHub Actions / Test (22.12.x, ubuntu-latest)

test/module-type-prebuildify.ts

Error: Cannot find module '../lib/module-type/prebuildify.js' imported from '/home/runner/work/rebuild/rebuild/test/module-type-prebuildify.ts' ❯ test/module-type-prebuildify.ts:5:1 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { code: 'ERR_MODULE_NOT_FOUND' } Caused by: Caused by: Error: Failed to load url ../lib/module-type/prebuildify.js (resolved id: ../lib/module-type/prebuildify.js) in /home/runner/work/rebuild/rebuild/test/module-type-prebuildify.ts. Does the file exist? ❯ loadAndTransform node_modules/vite/dist/node/chunks/dep-Bn81Esdm.js:35725:17
determineNativePrebuildArch,
determineNativePrebuildExtension,
Prebuildify
Expand Down
2 changes: 1 addition & 1 deletion test/read-package-json.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import path from 'node:path';
import { expect } from 'chai';
import { describe, expect, it } from 'vitest';

import { readPackageJson } from '../lib/read-package-json.js';

Check failure on line 4 in test/read-package-json.ts

View workflow job for this annotation

GitHub Actions / Test (22.12.x, macos-latest)

test/read-package-json.ts

Error: Cannot find module '../lib/read-package-json.js' imported from '/Users/runner/work/rebuild/rebuild/test/read-package-json.ts' ❯ test/read-package-json.ts:4:1 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { code: 'ERR_MODULE_NOT_FOUND' } Caused by: Caused by: Error: Failed to load url ../lib/read-package-json.js (resolved id: ../lib/read-package-json.js) in /Users/runner/work/rebuild/rebuild/test/read-package-json.ts. Does the file exist? ❯ loadAndTransform node_modules/vite/dist/node/chunks/dep-Bn81Esdm.js:35725:17

Check failure on line 4 in test/read-package-json.ts

View workflow job for this annotation

GitHub Actions / Test (22.12.x, ubuntu-latest)

test/read-package-json.ts

Error: Cannot find module '../lib/read-package-json.js' imported from '/home/runner/work/rebuild/rebuild/test/read-package-json.ts' ❯ test/read-package-json.ts:4:1 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { code: 'ERR_MODULE_NOT_FOUND' } Caused by: Caused by: Error: Failed to load url ../lib/read-package-json.js (resolved id: ../lib/read-package-json.js) in /home/runner/work/rebuild/rebuild/test/read-package-json.ts. Does the file exist? ❯ loadAndTransform node_modules/vite/dist/node/chunks/dep-Bn81Esdm.js:35725:17
import { pathToFileURL } from 'node:url';

describe('read-package-json', () => {
Expand Down
12 changes: 5 additions & 7 deletions test/rebuild-napibuildversion.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import fs from 'graceful-fs';
import path from 'node:path';
import { afterAll, beforeAll, describe, expect, it } from 'vitest';

import { expect } from 'chai';
import { rebuild } from '../lib/rebuild.js';

Check failure on line 5 in test/rebuild-napibuildversion.ts

View workflow job for this annotation

GitHub Actions / Test (22.12.x, macos-latest)

test/rebuild-napibuildversion.ts

Error: Cannot find module '../lib/rebuild.js' imported from '/Users/runner/work/rebuild/rebuild/test/rebuild-napibuildversion.ts' ❯ test/rebuild-napibuildversion.ts:5:1 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { code: 'ERR_MODULE_NOT_FOUND' } Caused by: Caused by: Error: Failed to load url ../lib/rebuild.js (resolved id: ../lib/rebuild.js) in /Users/runner/work/rebuild/rebuild/test/rebuild.ts. Does the file exist? ❯ loadAndTransform node_modules/vite/dist/node/chunks/dep-Bn81Esdm.js:35725:17

Check failure on line 5 in test/rebuild-napibuildversion.ts

View workflow job for this annotation

GitHub Actions / Test (22.12.x, ubuntu-latest)

test/rebuild-napibuildversion.ts

Error: Cannot find module '../lib/rebuild.js' imported from '/home/runner/work/rebuild/rebuild/test/rebuild-napibuildversion.ts' ❯ test/rebuild-napibuildversion.ts:5:1 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { code: 'ERR_MODULE_NOT_FOUND' } Caused by: Caused by: Error: Failed to load url ../lib/rebuild.js (resolved id: ../lib/rebuild.js) in /home/runner/work/rebuild/rebuild/test/rebuild.ts. Does the file exist? ❯ loadAndTransform node_modules/vite/dist/node/chunks/dep-Bn81Esdm.js:35725:17
import { getExactElectronVersionSync } from './helpers/electron-version.js';
import { TIMEOUT_IN_MILLISECONDS, TEST_MODULE_PATH as testModulePath, cleanupTestModule, resetTestModule } from './helpers/module-setup.js';
import { expectNativeModuleToBeRebuilt } from './helpers/rebuild.js';
Expand All @@ -10,18 +10,16 @@

const testElectronVersion = getExactElectronVersionSync();

describe('rebuild with napi_build_versions in binary config', async function () {
this.timeout(TIMEOUT_IN_MILLISECONDS);

describe('rebuild with napi_build_versions in binary config', { timeout: TIMEOUT_IN_MILLISECONDS }, async () => {
const napiBuildVersion = 6;
const napiBuildVersionSpecificPath = (arch: string, libc: string) => path.resolve(testModulePath, `node_modules/sqlite3/lib/binding/napi-v${ napiBuildVersion }-${ process.platform }-${ libc }-${ arch }/node_sqlite3.node`);

before(async () => {
beforeAll(async () => {
await resetTestModule(testModulePath, true, 'napi-build-version');
// Forcing `msvs_version` needed in order for `arm64` `win32` binary to be built
process.env.GYP_MSVS_VERSION = process.env.GYP_MSVS_VERSION ?? "2019";
});
after(() => cleanupTestModule(testModulePath));
}, TIMEOUT_IN_MILLISECONDS);
afterAll(() => cleanupTestModule(testModulePath), TIMEOUT_IN_MILLISECONDS);

// https://github.com/electron/rebuild/issues/554
const archs = ['x64', 'arm64'];
Expand Down
11 changes: 5 additions & 6 deletions test/rebuild-yarnworkspace.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
import path from 'node:path';
import { afterAll, beforeAll, describe, it } from 'vitest';

import { expectNativeModuleToBeRebuilt, expectNativeModuleToNotBeRebuilt } from './helpers/rebuild.js';
import { getExactElectronVersionSync } from './helpers/electron-version.js';
import { getProjectRootPath } from '../lib/search-module.js';

Check failure on line 6 in test/rebuild-yarnworkspace.ts

View workflow job for this annotation

GitHub Actions / Test (22.12.x, macos-latest)

test/rebuild-yarnworkspace.ts

Error: Cannot find module '../lib/search-module.js' imported from '/Users/runner/work/rebuild/rebuild/test/rebuild-yarnworkspace.ts' ❯ test/rebuild-yarnworkspace.ts:6:1 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { code: 'ERR_MODULE_NOT_FOUND' } Caused by: Caused by: Error: Failed to load url ../lib/search-module.js (resolved id: ../lib/search-module.js) in /Users/runner/work/rebuild/rebuild/test/search-module.ts. Does the file exist? ❯ loadAndTransform node_modules/vite/dist/node/chunks/dep-Bn81Esdm.js:35725:17

Check failure on line 6 in test/rebuild-yarnworkspace.ts

View workflow job for this annotation

GitHub Actions / Test (22.12.x, ubuntu-latest)

test/rebuild-yarnworkspace.ts

Error: Cannot find module '../lib/search-module.js' imported from '/home/runner/work/rebuild/rebuild/test/rebuild-yarnworkspace.ts' ❯ test/rebuild-yarnworkspace.ts:6:1 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { code: 'ERR_MODULE_NOT_FOUND' } Caused by: Caused by: Error: Failed to load url ../lib/search-module.js (resolved id: ../lib/search-module.js) in /home/runner/work/rebuild/rebuild/test/search-module.ts. Does the file exist? ❯ loadAndTransform node_modules/vite/dist/node/chunks/dep-Bn81Esdm.js:35725:17
import { rebuild } from '../lib/rebuild.js';
import { TIMEOUT_IN_MILLISECONDS, TEST_MODULE_PATH as testModulePath, cleanupTestModule, resetTestModule } from './helpers/module-setup.js';

const testElectronVersion = getExactElectronVersionSync();

describe('rebuild for yarn workspace', function() {
this.timeout(TIMEOUT_IN_MILLISECONDS);

describe('rebuild for yarn workspace', { timeout: TIMEOUT_IN_MILLISECONDS }, () => {
describe('core behavior', () => {
before(async () => {
beforeAll(async () => {
await resetTestModule(testModulePath, true, 'workspace-test');
const projectRootPath = await getProjectRootPath(path.join(testModulePath, 'workspace-test', 'child-workspace'));

Expand All @@ -22,8 +21,8 @@
arch: process.arch,
projectRootPath
});
});
after(() => cleanupTestModule(testModulePath));
}, TIMEOUT_IN_MILLISECONDS);
afterAll(() => cleanupTestModule(testModulePath), TIMEOUT_IN_MILLISECONDS);

it('should have rebuilt top level prod dependencies', async () => {
await expectNativeModuleToBeRebuilt(testModulePath, 'snappy');
Expand Down
Loading
Loading