Skip to content

Commit 09018b0

Browse files
authored
Merge pull request #98 from aminya/esm
2 parents 2c84fbf + 97b3cce commit 09018b0

13 files changed

+33
-12
lines changed

cspell.config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ words:
2626
- devel
2727
- dyld
2828
- eabi
29+
- esmodule
2930
- execa
3031
- ftxui
3132
- gcovr

dist/actions_python.aa574a9a.js

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

dist/actions_python.aa574a9a.js.map

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

dist/setup_cpp.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/setup_cpp.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/setup_cpp.mjs

Lines changed: 2 additions & 0 deletions
Large diffs are not rendered by default.

dist/setup_cpp.mjs.map

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

jest.config.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
module.exports = {
2-
preset: "ts-jest/presets/default-esm",
2+
preset: "ts-jest/presets/js-with-ts-esm",
3+
extensionsToTreatAsEsm: [".ts"],
4+
transformIgnorePatterns: [], // transform everything
35
testEnvironment: "node",
46
testMatch: ["**/*.test.ts"],
57
testPathIgnorePatterns: ["<rootDir>/src/python/setup-python/"],

package.json

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@
55
"repository": "https://github.com/aminya/setup-cpp",
66
"license": "Apache-2.0",
77
"author": "Amin Yahyaabadi",
8+
"exports": {
9+
"import": "./dist/setup-cpp.mjs",
10+
"require": "./dist/setup-cpp.js"
11+
},
812
"main": "./dist/setup_cpp.js",
13+
"module": "./dist/setup_cpp.mjs",
914
"source": "./src/main.ts",
1015
"bin": {
1116
"setup-cpp": "./dist/setup_cpp.js",
@@ -121,7 +126,14 @@
121126
"main": {
122127
"context": "node",
123128
"includeNodeModules": true,
124-
"optimize": true
129+
"optimize": true,
130+
"outputFormat": "commonjs"
131+
},
132+
"module": {
133+
"context": "node",
134+
"includeNodeModules": true,
135+
"optimize": true,
136+
"outputFormat": "esmodule"
125137
}
126138
}
127139
}

src/python/__tests__/python.test.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { cleanupTmpDir, setupTmpDir, testBin } from "../../utils/tests/test-help
33
import { getVersion } from "../../default_versions"
44
import { ubuntuVersion } from "../../utils/env/ubuntu_version"
55
import { isGitHubCI } from "../../utils/env/isci"
6+
import { info } from "../../utils/io/io"
67

78
jest.setTimeout(300000)
89
describe("setup-python", () => {
@@ -13,13 +14,11 @@ describe("setup-python", () => {
1314

1415
it("should setup python in GitHub Actions", async () => {
1516
if (isGitHubCI()) {
16-
const installInfo = await setupPython(
17-
getVersion("python", "true", await ubuntuVersion()),
18-
directory,
19-
process.arch
20-
)
17+
info("Installing python in GitHub Actions")
18+
const { setupActionsPython } = await import("../actions_python")
19+
await setupActionsPython(getVersion("python", "true", await ubuntuVersion()), directory, process.arch)
2120

22-
await testBin("python", ["--version"], installInfo?.binDir)
21+
await testBin("python", ["--version"])
2322
}
2423
})
2524

src/python/python.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export async function setupPython(version: string, setupDir: string, arch: strin
1616
return setupPythonViaSystem(version, setupDir, arch)
1717
}
1818
try {
19+
info("Installing python in GitHub Actions")
1920
const { setupActionsPython } = await import("./actions_python")
2021
return setupActionsPython(version, setupDir, arch)
2122
} catch (err) {

src/utils/tests/test-helpers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,5 @@ export async function testBin(
4949
expect(status).toBe(0)
5050
}
5151

52-
expect(await io.which(name, true)).toBe(bin)
52+
expect((await io.which(name, true)).includes(bin))
5353
}

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"allowJs": true,
2323
"esModuleInterop": true,
2424
"resolveJsonModule": true,
25-
"module": "commonjs",
25+
"module": "esnext",
2626
"moduleResolution": "node",
2727
"importHelpers": false,
2828
"outDir": "./dist"

0 commit comments

Comments
 (0)