Skip to content

Commit dde95f4

Browse files
committed
refactor: Use import.meta.dirname
1 parent 545c6d0 commit dde95f4

File tree

18 files changed

+19
-51
lines changed

18 files changed

+19
-51
lines changed

packages/auto-approver/src/AutoApprover.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import fs from 'node:fs';
22
import path from 'node:path';
3-
import {fileURLToPath} from 'node:url';
43
import axios, {AxiosError, AxiosInstance} from 'axios';
54
import logdown from 'logdown';
65

@@ -9,8 +8,7 @@ interface PackageJson {
98
version: string;
109
}
1110

12-
const __filename = fileURLToPath(import.meta.url);
13-
const __dirname = path.dirname(__filename);
11+
const __dirname = import.meta.dirname;
1412
const packageJsonPath = path.join(__dirname, '../package.json');
1513

1614
const {bin, version: toolVersion}: PackageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));

packages/auto-approver/src/cli.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import fs from 'node:fs';
44
import path from 'node:path';
55
import readline from 'node:readline';
6-
import {fileURLToPath} from 'node:url';
76
import {program as commander} from 'commander';
87
import {cosmiconfigSync} from 'cosmiconfig';
98
import logdown from 'logdown';
@@ -24,8 +23,7 @@ interface PackageJson {
2423
version: string;
2524
}
2625

27-
const __filename = fileURLToPath(import.meta.url);
28-
const __dirname = path.dirname(__filename);
26+
const __dirname = import.meta.dirname;
2927
const packageJsonPath = path.join(__dirname, '../package.json');
3028

3129
const {bin, description, version}: PackageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));

packages/crates-updater/src/cli.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import fs from 'node:fs';
44
import path from 'node:path';
5-
import {fileURLToPath} from 'node:url';
65
import {program as commander} from 'commander';
76

87
import * as CratesUpdater from './CratesUpdater.js';
@@ -12,8 +11,8 @@ interface PackageJson {
1211
description: string;
1312
version: string;
1413
}
15-
const __filename = fileURLToPath(import.meta.url);
16-
const __dirname = path.dirname(__filename);
14+
15+
const __dirname = import.meta.dirname;
1716
const packageJsonPath = path.join(__dirname, '../package.json');
1817

1918
const {bin, description, version}: PackageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));

packages/electron-icon-generator/src/cli.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import fs from 'node:fs';
44
import path from 'node:path';
5-
import {fileURLToPath} from 'node:url';
65
import {program as commander} from 'commander';
76

87
import {IconGenerator} from './index.js';
@@ -13,8 +12,7 @@ interface PackageJson {
1312
version: string;
1413
}
1514

16-
const __filename = fileURLToPath(import.meta.url);
17-
const __dirname = path.dirname(__filename);
15+
const __dirname = import.meta.dirname;
1816
const packageJsonPath = path.join(__dirname, '../package.json');
1917

2018
const {bin, description, version}: PackageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));

packages/electron-info/src/ElectronInfo.test.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import path from 'node:path';
2-
import {fileURLToPath} from 'node:url';
32
import {randomUUID} from 'node:crypto';
43
import {expect, describe, test, beforeEach, beforeAll, afterAll, afterEach} from 'vitest';
54
import {StatusCodes as HTTP_STATUS} from 'http-status-codes';
@@ -8,8 +7,7 @@ import fs from 'fs-extra';
87

98
import {ElectronInfo, RawReleaseInfo} from './ElectronInfo.js';
109

11-
const __filename = fileURLToPath(import.meta.url);
12-
const __dirname = path.dirname(__filename);
10+
const __dirname = import.meta.dirname;
1311
const tempDir = path.resolve(__dirname, '.temp');
1412
const tempDirDownload = path.resolve(__dirname, '.temp/download');
1513
const mockUrl = 'http://example.com';

packages/electron-info/src/cli.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import fs from 'node:fs';
44
import path from 'node:path';
5-
import {fileURLToPath} from 'node:url';
65
import {program as commander} from 'commander';
76

87
import {ElectronInfo, RawDeps, SupportedDependencies} from './ElectronInfo.js';
@@ -13,8 +12,7 @@ interface PackageJson {
1312
version: string;
1413
}
1514

16-
const __filename = fileURLToPath(import.meta.url);
17-
const __dirname = path.dirname(__filename);
15+
const __dirname = import.meta.dirname;
1816
const packageJsonPath = path.join(__dirname, '../package.json');
1917

2018
const {description, name, version}: PackageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));

packages/gh-open/src/cli.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import path from 'node:path';
44
import fs from 'node:fs';
5-
import {fileURLToPath} from 'node:url';
65
import {program as commander} from 'commander';
76
import {findUp} from 'find-up';
87
import open from 'open';
@@ -15,8 +14,7 @@ interface PackageJson {
1514
version: string;
1615
}
1716

18-
const __filename = fileURLToPath(import.meta.url);
19-
const __dirname = path.dirname(__filename);
17+
const __dirname = import.meta.dirname;
2018
const packageJsonPath = path.join(__dirname, '../package.json');
2119
const {description, name, version}: PackageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
2220

packages/https-proxy/src/cli.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import fs from 'node:fs';
44
import path from 'node:path';
5-
import {fileURLToPath} from 'node:url';
65
import {program as commander} from 'commander';
76

87
import {HttpsProxy} from './HttpsProxy.js';
@@ -13,8 +12,7 @@ interface PackageJson {
1312
version: string;
1413
}
1514

16-
const __filename = fileURLToPath(import.meta.url);
17-
const __dirname = path.dirname(__filename);
15+
const __dirname = import.meta.dirname;
1816
const packageJsonPath = path.join(__dirname, '../package.json');
1917

2018
const {description, name, version}: PackageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));

packages/jszip-cli/src/cli.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
#!/usr/bin/env node
22

33
import path from 'node:path';
4-
import {fileURLToPath} from 'node:url';
54
import {program as commander} from 'commander';
65
import fs from 'fs-extra';
76

87
import {JSZipCLI} from './JSZipCLI.js';
98

10-
const __filename = fileURLToPath(import.meta.url);
11-
const __dirname = path.dirname(__filename);
9+
const __dirname = import.meta.dirname;
1210
const packageJsonPath = path.join(__dirname, '../package.json');
1311

1412
const {description, name, version}: {description: string; name: string; version: string} =

packages/mastodon-bot-yearprogress/src/cli.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import * as fs from 'node:fs';
44
import * as path from 'node:path';
5-
import {fileURLToPath} from 'node:url';
65
import {program as commander} from 'commander';
76

87
import {YearProgressClient} from './YearProgressClient.js';
@@ -15,8 +14,7 @@ interface CommanderOptions {
1514
token?: string;
1615
}
1716

18-
const __filename = fileURLToPath(import.meta.url);
19-
const __dirname = path.dirname(__filename);
17+
const __dirname = import.meta.dirname;
2018
const packageJsonPath = path.join(__dirname, '../package.json');
2119

2220
const packageJson = fs.readFileSync(packageJsonPath, 'utf-8');

0 commit comments

Comments
 (0)