Skip to content

Commit

Permalink
ES Module
Browse files Browse the repository at this point in the history
  • Loading branch information
SnowCait committed Feb 17, 2023
1 parent 6a4bf15 commit 80f7624
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 9 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"SharedArrayBuffer": "readonly"
},
"parserOptions": {
"ecmaVersion": 2018
"ecmaVersion": 13,
"sourceType": "module"
},
"rules": {
}
Expand Down
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const core = require('@actions/core');
const wait = require('./wait');
import core from '@actions/core';
import { wait } from './wait.js';


// most @actions toolkit packages have async methods
Expand Down
12 changes: 8 additions & 4 deletions index.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
const wait = require('./wait');
const process = require('process');
const cp = require('child_process');
const path = require('path');
import { wait } from './wait.js';
import process from 'process';
import cp from 'child_process';
import path from 'path';
import { fileURLToPath } from 'url';

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

test('throws invalid number', async () => {
await expect(wait('foo')).rejects.toThrow('milliseconds not a number');
Expand Down
4 changes: 4 additions & 0 deletions jest.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"verbose": true,
"transform": {}
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
"version": "1.0.0",
"description": "JavaScript Action Template",
"main": "index.js",
"type": "module",
"scripts": {
"lint": "eslint .",
"prepare": "ncc build index.js -o dist --source-map --license licenses.txt",
"test": "jest",
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
"all": "npm run lint && npm run prepare && npm run test"
},
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion wait.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ let wait = function (milliseconds) {
});
};

module.exports = wait;
export { wait };

0 comments on commit 80f7624

Please sign in to comment.