Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add support for Es modules #98

Merged
merged 3 commits into from
Jul 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cspell.config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ words:
- devel
- dyld
- eabi
- esmodule
- execa
- ftxui
- gcovr
Expand Down
2 changes: 2 additions & 0 deletions dist/actions_python.aa574a9a.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dist/actions_python.aa574a9a.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/setup_cpp.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/setup_cpp.js.map

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions dist/setup_cpp.mjs

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dist/setup_cpp.mjs.map

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module.exports = {
preset: "ts-jest/presets/default-esm",
preset: "ts-jest/presets/js-with-ts-esm",
extensionsToTreatAsEsm: [".ts"],
transformIgnorePatterns: [], // transform everything
testEnvironment: "node",
testMatch: ["**/*.test.ts"],
testPathIgnorePatterns: ["<rootDir>/src/python/setup-python/"],
Expand Down
14 changes: 13 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@
"repository": "https://github.com/aminya/setup-cpp",
"license": "Apache-2.0",
"author": "Amin Yahyaabadi",
"exports": {
"import": "./dist/setup-cpp.mjs",
"require": "./dist/setup-cpp.js"
},
"main": "./dist/setup_cpp.js",
"module": "./dist/setup_cpp.mjs",
"source": "./src/main.ts",
"bin": {
"setup-cpp": "./dist/setup_cpp.js",
Expand Down Expand Up @@ -121,7 +126,14 @@
"main": {
"context": "node",
"includeNodeModules": true,
"optimize": true
"optimize": true,
"outputFormat": "commonjs"
},
"module": {
"context": "node",
"includeNodeModules": true,
"optimize": true,
"outputFormat": "esmodule"
}
}
}
11 changes: 5 additions & 6 deletions src/python/__tests__/python.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { cleanupTmpDir, setupTmpDir, testBin } from "../../utils/tests/test-help
import { getVersion } from "../../default_versions"
import { ubuntuVersion } from "../../utils/env/ubuntu_version"
import { isGitHubCI } from "../../utils/env/isci"
import { info } from "../../utils/io/io"

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

it("should setup python in GitHub Actions", async () => {
if (isGitHubCI()) {
const installInfo = await setupPython(
getVersion("python", "true", await ubuntuVersion()),
directory,
process.arch
)
info("Installing python in GitHub Actions")
const { setupActionsPython } = await import("../actions_python")
await setupActionsPython(getVersion("python", "true", await ubuntuVersion()), directory, process.arch)

await testBin("python", ["--version"], installInfo?.binDir)
await testBin("python", ["--version"])
}
})

Expand Down
1 change: 1 addition & 0 deletions src/python/python.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export async function setupPython(version: string, setupDir: string, arch: strin
return setupPythonViaSystem(version, setupDir, arch)
}
try {
info("Installing python in GitHub Actions")
const { setupActionsPython } = await import("./actions_python")
return setupActionsPython(version, setupDir, arch)
} catch (err) {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/tests/test-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,5 @@ export async function testBin(
expect(status).toBe(0)
}

expect(await io.which(name, true)).toBe(bin)
expect((await io.which(name, true)).includes(bin))
}
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"allowJs": true,
"esModuleInterop": true,
"resolveJsonModule": true,
"module": "commonjs",
"module": "esnext",
"moduleResolution": "node",
"importHelpers": false,
"outDir": "./dist"
Expand Down