This commit is contained in:
Oleg Maslov
2026-09-02 10:14:22 +02:00
parent 0c3e2ead3b
commit b20b138fe4
771 changed files with 161561 additions and 9027 deletions

View File

@@ -0,0 +1,17 @@
import { resolve } from 'node:path';
import { pathToFileURL } from 'node:url';
import { describe, expect, it } from 'vitest';
import { isDirectExecution } from '../src/main-module.js';
describe('isDirectExecution', () => {
it('matches an argv filesystem path to its canonical file URL', () => {
const scriptPath = resolve('fixtures', 'hook #1.js');
expect(isDirectExecution(pathToFileURL(scriptPath).href, scriptPath)).toBe(true);
});
it('rejects a different entrypoint or missing argv path', () => {
const modulePath = resolve('fixtures', 'hook.js');
expect(isDirectExecution(pathToFileURL(modulePath).href, resolve('fixtures', 'other.js'))).toBe(false);
expect(isDirectExecution(pathToFileURL(modulePath).href, '')).toBe(false);
});
});