Skip to content

Commit 4d2f1be

Browse files
committed
chore: clean up & rm esm-utils
1 parent 57b38c0 commit 4d2f1be

File tree

9 files changed

+16
-53
lines changed

9 files changed

+16
-53
lines changed

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
"debug": "^4.3.5",
4646
"dl-vampire": "^2.1.2",
4747
"env-paths": "3",
48-
"esm-utils": "^4.3.0",
4948
"fs-extra": "^11.2.0",
5049
"less": "^4.2.0",
5150
"log-symbols": "^6.0.0",

pnpm-lock.yaml

Lines changed: 0 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/cli.ts

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
#!/usr/bin/env node
22

33
import { Builtins, Cli } from 'clipanion'
4-
import esmUtils from 'esm-utils'
5-
6-
const { require } = esmUtils(import.meta)
7-
const { version, name, bin } = require('../package.json') as CurrentPackageJson
4+
import { AddCommand } from './commands/add'
5+
import { ListCommand } from './commands/list'
6+
import { RemoveCommand } from './commands/remove'
7+
import { UpdateCommand } from './commands/update'
8+
import { currentPackageJson } from './pkg'
89

9-
const [node, app, ...args] = process.argv
10+
const { version, name, bin } = currentPackageJson
1011
const cli = new Cli({
1112
binaryLabel: name,
1213
binaryName: Object.keys(bin)[0],
@@ -16,19 +17,10 @@ const cli = new Cli({
1617
cli.register(Builtins.HelpCommand)
1718
cli.register(Builtins.VersionCommand)
1819
cli.register(Builtins.DefinitionsCommand)
19-
20-
// more commands
21-
import { AddCommand } from './commands/add'
2220
cli.register(AddCommand)
23-
24-
import { RemoveCommand } from './commands/remove'
2521
cli.register(RemoveCommand)
26-
27-
import { UpdateCommand } from './commands/update'
2822
cli.register(UpdateCommand)
29-
30-
import { ListCommand } from './commands/list'
31-
import type { CurrentPackageJson } from './utils/types'
3223
cli.register(ListCommand)
3324

25+
const [node, app, ...args] = process.argv
3426
cli.runExit(args, Cli.defaultContext)

src/data.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
import consola from 'consola'
22
import envPaths from 'env-paths'
3-
import esmUtils from 'esm-utils'
43
import fse from 'fs-extra'
54
import path from 'path'
6-
import type { CurrentPackageJson } from './utils/types'
5+
import { currentPackageJson } from './pkg'
76

8-
const { require } = esmUtils(import.meta)
9-
const { name } = require('../package.json') as CurrentPackageJson
10-
const paths = envPaths(name, { suffix: '' })
7+
const paths = envPaths(currentPackageJson.name, { suffix: '' })
118

129
export type AddedAsset = { file: string; disabled: boolean }
1310

src/define/code.ts

Lines changed: 0 additions & 7 deletions
This file was deleted.

src/pkg.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { createRequire } from 'module'
2+
import type { CurrentPackageJson } from './utils/types'
3+
4+
const require = createRequire(__filename)
5+
export const currentPackageJson = require('../package.json') as CurrentPackageJson

src/typings.d.ts

Whitespace-only changes.

src/utils/checksum.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
import { createHash } from 'crypto'
2-
import esmUtils from 'esm-utils'
32
import fse from 'fs-extra'
43
import path from 'path'
54
import { APP_DIR } from '../config'
65

7-
const { require } = esmUtils(import.meta)
8-
96
/**
107
* https://github.com/lehni/vscode-fix-checksums/blob/1943e4f21251fdf2bc93479e7d391a906a00e9b1/extension.js#L27
118
*
@@ -20,7 +17,7 @@ export function computeChecksum(file: string) {
2017

2118
export function checkChecksum() {
2219
const productFile = path.join(APP_DIR, 'product.json')
23-
const product = require(productFile)
20+
const product = fse.readJSONSync(productFile)
2421
let changed = false
2522

2623
for (const [filePath, curChecksum] of Object.entries(product.checksums)) {

tsup.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export default defineConfig((options) => {
66
format: 'esm',
77
target: 'node18',
88
clean: true,
9+
shims: true, // with this, free to use `__dirname` / `__filename` / `import.meta.dirname` / `import.meta.filename`
910
esbuildOptions(options, context) {
1011
options.charset = 'utf8'
1112
},

0 commit comments

Comments
 (0)