-
-
Save brieb/e055e8df36769862bf2907893b3f9a81 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -euo pipefail | |
node -r ./babel-node.register "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const path = require('path'); | |
require('@babel/register')({ | |
extensions: ['.js', '.jsx', '.ts', '.tsx'], | |
// ... more config ... | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -euo pipefail | |
./babel-node ./jest-ts-run.ts "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { run } from 'jest'; | |
import path from 'path'; | |
const argsIn = process.argv.slice(2); | |
const argsOut: string[] = []; | |
let configFile; | |
let i = 0; | |
while (i < argsIn.length) { | |
if (argsIn[i].startsWith('--config')) { | |
if (argsIn[i].startsWith('--config=')) { | |
configFile = argsIn[i].replace('--config=', ''); | |
} else if (i + 1 < argsIn.length) { | |
configFile = argsIn[i + 1]; | |
i++; | |
} | |
} else { | |
argsOut.push(argsIn[i]); | |
} | |
i++; | |
} | |
if (!configFile) { | |
throw new Error('Missing --config'); | |
} | |
let config; | |
if (configFile.endsWith('.ts')) { | |
config = JSON.stringify(require(path.resolve(configFile))); | |
} else { | |
config = configFile; | |
} | |
argsOut.unshift('--config', config); | |
run(argsOut); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment