Skip to content

Commit

Permalink
refactor: do not use URL()
Browse files Browse the repository at this point in the history
  • Loading branch information
sinedied committed Jan 2, 2025
1 parent 749d6b7 commit bf420ac
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
5 changes: 4 additions & 1 deletion smoke-cli.js
Original file line number Diff line number Diff line change
@@ -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 [<mocks_folder>] [options]
Base options:
Expand Down Expand Up @@ -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);
}

Expand Down
5 changes: 4 additions & 1 deletion smoke-conv-cli.js
Original file line number Diff line number Diff line change
@@ -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 <input_mocks_or_collection> <output_file_or_folder>
Convert a single file mock collection to separate mock files and conversely.
Expand Down Expand Up @@ -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);
}

Expand Down
5 changes: 4 additions & 1 deletion test/convert.spec.js
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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;
Expand Down

0 comments on commit bf420ac

Please sign in to comment.