-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathglobal.ts
More file actions
27 lines (24 loc) · 824 Bytes
/
global.ts
File metadata and controls
27 lines (24 loc) · 824 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import 'reflect-metadata';
import tsconfig from './tsconfig.json';
import { register } from 'tsconfig-paths';
import path from 'path';
import coffee from 'coffee';
import fs from 'fs';
import { ForkOptions } from 'child_process';
import assert from 'node:assert';
register({
baseUrl: tsconfig.compilerOptions.baseUrl,
paths: tsconfig.compilerOptions.paths,
});
export function fork(target: string, args: string[] = [], options: ForkOptions = {}) {
const bin = [
path.join(__dirname, target, 'src/bin/cli.ts'),
path.join(__dirname, target, 'src/bin.ts'),
].find(p => fs.existsSync(p));
assert(bin, `${target} cannot found bin file`);
return coffee.fork(bin, args, {
cwd: __dirname,
execArgv: [ '-r', require.resolve('ts-node/register') ].concat(options.execArgv || []),
...options,
});
}