evals 2.2.2 → 2.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "evals",
3
- "version": "2.2.2",
3
+ "version": "2.2.3",
4
4
  "description": "Arize evals package",
5
5
  "type": "module",
6
6
  "main": "cli.js",
@@ -1,6 +1,30 @@
1
- import { execSync } from 'child_process';
1
+ import { spawn } from 'child_process';
2
+ import { openSync } from 'fs';
2
3
 
3
- execSync('node ./cli.js < /dev/tty > /dev/tty 2>&1', {
4
- stdio: 'inherit',
5
- shell: true
6
- });
4
+ function tryOpenTTY() {
5
+ try {
6
+ const device = process.platform === 'win32' ? 'CON' : '/dev/tty';
7
+ openSync(device, 'r');
8
+ return { device, available: true };
9
+ } catch (err) {
10
+ return { available: false };
11
+ }
12
+ }
13
+
14
+ const tty = tryOpenTTY();
15
+
16
+ if (tty.available) {
17
+ const child = spawn('node', ['./cli.js'], {
18
+ stdio: [
19
+ openSync(tty.device, 'r'),
20
+ openSync(tty.device, 'w'),
21
+ openSync(tty.device, 'w')
22
+ ]
23
+ });
24
+
25
+ child.on('close', (code) => {
26
+ process.exit(code);
27
+ });
28
+ } else {
29
+ console.log('Run `npx evals` to complete setup.');
30
+ }