@myerscarpenter/quest-dev 1.0.0

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.
@@ -0,0 +1,83 @@
1
+ /**
2
+ * Shell command execution utilities
3
+ */
4
+
5
+ import { spawn } from 'child_process';
6
+
7
+ export interface ExecResult {
8
+ stdout: string;
9
+ stderr: string;
10
+ code: number;
11
+ }
12
+
13
+ /**
14
+ * Execute a shell command and return a promise with stdout
15
+ */
16
+ export function execCommand(command: string, args: string[] = []): Promise<string> {
17
+ return new Promise((resolve, reject) => {
18
+ const proc = spawn(command, args, {
19
+ stdio: 'pipe',
20
+ shell: true
21
+ });
22
+
23
+ let stdout = '';
24
+ let stderr = '';
25
+
26
+ if (proc.stdout) {
27
+ proc.stdout.on('data', (data) => {
28
+ stdout += data.toString();
29
+ });
30
+ }
31
+
32
+ if (proc.stderr) {
33
+ proc.stderr.on('data', (data) => {
34
+ stderr += data.toString();
35
+ });
36
+ }
37
+
38
+ proc.on('close', (code) => {
39
+ if (code === 0) {
40
+ resolve(stdout);
41
+ } else {
42
+ reject(new Error(`Command failed with code ${code}: ${stderr}`));
43
+ }
44
+ });
45
+
46
+ proc.on('error', reject);
47
+ });
48
+ }
49
+
50
+ /**
51
+ * Execute a shell command and return full result (doesn't throw on non-zero exit)
52
+ */
53
+ export function execCommandFull(command: string, args: string[] = []): Promise<ExecResult> {
54
+ return new Promise((resolve) => {
55
+ const proc = spawn(command, args, {
56
+ stdio: 'pipe',
57
+ shell: true
58
+ });
59
+
60
+ let stdout = '';
61
+ let stderr = '';
62
+
63
+ if (proc.stdout) {
64
+ proc.stdout.on('data', (data) => {
65
+ stdout += data.toString();
66
+ });
67
+ }
68
+
69
+ if (proc.stderr) {
70
+ proc.stderr.on('data', (data) => {
71
+ stderr += data.toString();
72
+ });
73
+ }
74
+
75
+ proc.on('close', (code) => {
76
+ resolve({ stdout, stderr, code: code ?? 1 });
77
+ });
78
+
79
+ proc.on('error', (err) => {
80
+ resolve({ stdout, stderr: err.message, code: 1 });
81
+ });
82
+ });
83
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,21 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "NodeNext",
5
+ "moduleResolution": "NodeNext",
6
+ "lib": ["ES2022"],
7
+ "outDir": "./build",
8
+ "rootDir": "./src",
9
+ "strict": true,
10
+ "esModuleInterop": true,
11
+ "skipLibCheck": true,
12
+ "forceConsistentCasingInFileNames": true,
13
+ "resolveJsonModule": true,
14
+ "declaration": true,
15
+ "declarationMap": true,
16
+ "sourceMap": true,
17
+ "types": ["node"]
18
+ },
19
+ "include": ["src/**/*"],
20
+ "exclude": ["node_modules", "build"]
21
+ }