Skip to content

Commit e50d898

Browse files
committed
Migrate to ES modules
1 parent d109bcf commit e50d898

File tree

3 files changed

+20
-18
lines changed

3 files changed

+20
-18
lines changed

.eslintrc.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
"SharedArrayBuffer": "readonly"
1212
},
1313
"parserOptions": {
14-
"ecmaVersion": 2018
14+
"ecmaVersion": 2020,
15+
"sourceType": "module"
1516
},
1617
"rules": {
1718
"no-empty": ["error", {"allowEmptyCatch": true}],

index.js

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
1-
const Core = require("@actions/core");
2-
const ToolCache = require("@actions/tool-cache");
3-
const Cache = require("@actions/cache");
4-
const IO = require("@actions/io");
5-
const Glob = require("@actions/glob");
6-
const {Octokit} = require("@octokit/rest");
7-
const fetch = require("node-fetch");
8-
const Path = require("path");
9-
const ChildProcess = require("child_process");
10-
const Util = require("util");
11-
const FS = require("fs").promises;
12-
13-
const {cmpTags} = require("tag-cmp");
1+
import Core from "@actions/core";
2+
import ToolCache from "@actions/tool-cache";
3+
import Cache from "@actions/cache";
4+
import IO from "@actions/io";
5+
import Glob from "@actions/glob";
6+
import {Octokit} from "@octokit/rest";
7+
import fetch from "node-fetch";
8+
import Path from "path";
9+
import ChildProcess from "child_process";
10+
import Util from "util";
11+
import URL from "url";
12+
import {promises as FS} from "fs";
13+
14+
import {cmpTags} from "tag-cmp";
1415
const execFile = Util.promisify(ChildProcess.execFile);
1516

1617
async function run() {
@@ -53,7 +54,8 @@ async function run() {
5354
Core.info(stdout);
5455

5556
if (!Core.getInput("annotate") || Core.getBooleanInput("annotate")) {
56-
const matchersPath = Path.join(__dirname, ".github");
57+
const scriptDir = Path.dirname(URL.fileURLToPath(import.meta.url));
58+
const matchersPath = Path.join(scriptDir, ".github");
5759
Core.info(`::add-matcher::${Path.join(matchersPath, "crystal.json")}`);
5860
Core.info(`::add-matcher::${Path.join(matchersPath, "crystal-spec.json")}`);
5961
}
@@ -466,6 +468,4 @@ async function onlySubdir(path) {
466468
return path;
467469
}
468470

469-
if (require.main === module) {
470-
run();
471-
}
471+
run();

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"name": "install-crystal",
33
"description": "GitHub Action: Install Crystal programming language",
44
"main": "index.js",
5+
"type": "module",
56
"scripts": {
67
"start": "node index.js",
78
"lint": "eslint .",

0 commit comments

Comments
 (0)