Skip to content

Commit

Permalink
Revert back to tsx
Browse files Browse the repository at this point in the history
  • Loading branch information
octet-stream committed Jul 25, 2024
1 parent cbf8a0b commit 15f0554
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 226 deletions.
54 changes: 1 addition & 53 deletions ava.config.js
Original file line number Diff line number Diff line change
@@ -1,62 +1,10 @@
// @ts-check

/**
* @typedef {Object} ParsedVersion
*
* @prop {number} major
* @prop {number?} minor
* @prop {number?} patch
*/

/**
* @return {ParsedVersion}
*/
function parseVersion() {
const parsed = process.version.match(
/^v(?<major>[0-9]+)(?:\.(?<minor>[0-9]+)?)(?:\.(?<patch>[0-9]+))?/
)

if (parsed?.groups?.major == null) {
throw new Error("Can't extract Node.js version form process.version")
}

const major = Number.parseInt(parsed.groups.major, 10)
const [minor, patch] = [parsed.groups.minor, parsed.groups.patch].map(
value => (value ? Number.parseInt(value, 10) : null)
)

return {major, minor, patch}
}

/**
* @returns {boolean}
*/
function isOlderThanTwentyDotSix() {
const {major, minor} = parseVersion()

if (major > 20 || (major === 20 && minor && minor > 6)) {
return false
}

return true
}

/**
* @returns {string[]}
*/
const getTsimpArgs = () =>
isOlderThanTwentyDotSix()
? ["--loader", "tsimp/loader"]
: ["--import", "tsimp"]

export default {
failFast: true,
workerThreads: isOlderThanTwentyDotSix() === false,
workerThreads: false,
require: "global-jsdom/register",
extensions: {
ts: "module",
tsx: "module"
},
nodeArguments: ["--no-warnings", ...getTsimpArgs()],
files: ["src/**/*.test.{ts,tsx}"]
}
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
}
},
"scripts": {
"test": "ava",
"test": "cross-env NODE_OPTIONS=\"--no-warnings --import tsx\" ava",
"coverage": "c8 pnpm test",
"report": "c8 -r=html pnpm test",
"ci": "c8 pnpm test && c8 report --reporter=json",
Expand Down Expand Up @@ -88,7 +88,6 @@
"slate": "0.94.1",
"slate-react": "0.97.1",
"ts-expect": "1.3.0",
"tsimp": "2.0.11",
"tsup": "7.2.0",
"tsx": "^4.7.1",
"typescript": "5.1.6",
Expand Down
Loading

0 comments on commit 15f0554

Please sign in to comment.