|
| 1 | +#!/usr/bin/env node |
| 2 | + |
| 3 | +import os from 'node:os'; |
| 4 | +import path from 'node:path'; |
| 5 | +import url from 'node:url'; |
| 6 | +import process from 'node:process'; |
| 7 | +import childProcess from 'node:child_process'; |
| 8 | + |
| 9 | +const projectPath = path.dirname( |
| 10 | + path.dirname(url.fileURLToPath(import.meta.url)), |
| 11 | +); |
| 12 | + |
| 13 | +const platform = os.platform(); |
| 14 | + |
| 15 | +/* eslint-disable no-console */ |
| 16 | +async function main() { |
| 17 | + const tscArgs = [`-p`, path.join(projectPath, 'tsconfig.build.json')]; |
| 18 | + console.error('Running tsc:'); |
| 19 | + console.error(['tsc', ...tscArgs].join(' ')); |
| 20 | + childProcess.execFileSync('tsc', tscArgs, { |
| 21 | + stdio: ['inherit', 'inherit', 'inherit'], |
| 22 | + windowsHide: true, |
| 23 | + encoding: 'utf-8', |
| 24 | + shell: platform === 'win32' ? true : false, |
| 25 | + }); |
| 26 | + const jestArgs = []; |
| 27 | + console.error('Running jest:'); |
| 28 | + console.error(['jest', ...jestArgs].join(' ')); |
| 29 | + childProcess.execFileSync('jest', jestArgs, { |
| 30 | + env: { |
| 31 | + ...process.env, |
| 32 | + NODE_OPTIONS: '--experimental-vm-modules', |
| 33 | + }, |
| 34 | + stdio: ['inherit', 'inherit', 'inherit'], |
| 35 | + windowsHide: true, |
| 36 | + encoding: 'utf-8', |
| 37 | + shell: platform === 'win32' ? true : false, |
| 38 | + }); |
| 39 | +} |
| 40 | +/* eslint-enable no-console */ |
| 41 | + |
| 42 | +if (import.meta.url.startsWith('file:')) { |
| 43 | + const modulePath = url.fileURLToPath(import.meta.url); |
| 44 | + if (process.argv[1] === modulePath) { |
| 45 | + void main(); |
| 46 | + } |
| 47 | +} |
0 commit comments