Skip to content

Commit 7244bb4

Browse files
committed
refactor!: switch module format to ESM
1 parent 0b36106 commit 7244bb4

File tree

11 files changed

+319
-314
lines changed

11 files changed

+319
-314
lines changed

.eslintrc.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ rules:
3838
allowRegExp: false
3939
allowNever: false
4040
"@typescript-eslint/no-unnecessary-type-parameters": "off"
41+
n/no-missing-import: "off"
4142

4243
overrides:
4344
- files: ["**/*.js"]

action.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
/* eslint-disable @typescript-eslint/no-floating-promises, @typescript-eslint/no-require-imports, @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call */
2-
"use strict";
1+
import { main } from "./dist/main.js";
32

4-
const { main } = require("./dist/main.js");
5-
6-
main();
3+
await main();

bin/npm-publish.js

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,23 @@
11
#!/usr/bin/env node
2-
/* eslint-disable @typescript-eslint/no-require-imports, @typescript-eslint/use-unknown-in-catch-callback-variable, unicorn/prefer-module, unicorn/prefer-top-level-await */
3-
"use strict";
2+
import process from "node:process";
3+
import fs from "node:fs";
4+
import path from "node:path";
5+
import url from "node:url";
46

5-
const process = require("node:process");
6-
const { version } = require("../package.json");
7-
const { main } = require("../lib/cli/index.js");
7+
import { main } from "../lib/cli/index.js";
88

9-
main(process.argv.slice(2), version).catch((error) => {
9+
const dirname = path.dirname(url.fileURLToPath(import.meta.url));
10+
11+
// eslint-disable-next-line jsdoc/check-tag-names
12+
/** @type {{ version: string }} */
13+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
14+
const { version } = JSON.parse(
15+
fs.readFileSync(path.join(dirname, "../package.json"), "utf8")
16+
);
17+
18+
try {
19+
await main(process.argv.slice(2), version);
20+
} catch (error) {
1021
console.error(error);
1122
process.exitCode = 1;
12-
});
23+
}

0 commit comments

Comments
 (0)