diff --git a/package.json b/package.json index fb0dd97..e74503c 100644 --- a/package.json +++ b/package.json @@ -73,7 +73,8 @@ "unicorn/prevent-abbreviations": "off", "unicorn/no-array-reduce": "off", "unicorn/prefer-spread": "off", - "unicorn/no-await-expression-member": "off" + "unicorn/no-await-expression-member": "off", + "unicorn/import-style": "off" } }, "jest": { diff --git a/smoke-cli.js b/smoke-cli.js index 531c288..dbf3210 100644 --- a/smoke-cli.js +++ b/smoke-cli.js @@ -1,7 +1,10 @@ import fs from 'node:fs'; +import {dirname, join} from 'node:path'; +import {fileURLToPath} from 'node:url'; import minimist from 'minimist'; import {createServer, startServer} from './lib/smoke.js'; +const __dirname = dirname(fileURLToPath(import.meta.url)); const help = `Usage: smoke [] [options] Base options: @@ -50,7 +53,7 @@ export async function run(args) { }); if (options.version) { - const pkg = JSON.parse(fs.readFileSync(new URL('package.json', import.meta.url), 'utf8')); + const pkg = JSON.parse(fs.readFileSync(join(__dirname, 'package.json'), 'utf8')); return console.log(pkg.version); } diff --git a/smoke-conv-cli.js b/smoke-conv-cli.js index 523d516..c06ac31 100644 --- a/smoke-conv-cli.js +++ b/smoke-conv-cli.js @@ -1,7 +1,10 @@ import fs from 'node:fs'; +import {dirname, join} from 'node:path'; +import {fileURLToPath} from 'node:url'; import minimist from 'minimist'; import {convert} from './lib/convert.js'; +const __dirname = dirname(fileURLToPath(import.meta.url)); const help = `Usage: smoke-conv Convert a single file mock collection to separate mock files and conversely. @@ -32,7 +35,7 @@ export async function run(args) { }); if (options.version) { - const pkg = JSON.parse(fs.readFileSync(new URL('package.json', import.meta.url), 'utf8')); + const pkg = JSON.parse(fs.readFileSync(join(__dirname, 'package.json'), 'utf8')); return console.log(pkg.version); } diff --git a/test/convert.spec.js b/test/convert.spec.js index 130a164..28fb0ca 100644 --- a/test/convert.spec.js +++ b/test/convert.spec.js @@ -1,6 +1,9 @@ import process from 'node:process'; +import {dirname, join} from 'node:path'; +import {fileURLToPath} from 'node:url'; import {jest} from '@jest/globals'; +const __dirname = dirname(fileURLToPath(import.meta.url)); const originalFs = await import('node:fs/promises'); jest.unstable_mockModule('node:fs/promises', async () => { return { @@ -23,7 +26,7 @@ describe('smoke conversion tools', () => { beforeEach(async () => { jest.resetAllMocks(); - process.chdir(new URL('..', import.meta.url).pathname); + process.chdir(join(__dirname, '..')); console.log('current directory:', process.cwd()); convert = (await import('../lib/convert.js')).convert; fs = (await import('node:fs/promises')).default;