aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/packages/turbo-codemod/src/commands/migrate/utils.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/turbo-codemod/src/commands/migrate/utils.ts')
-rw-r--r--packages/turbo-codemod/src/commands/migrate/utils.ts16
1 files changed, 16 insertions, 0 deletions
diff --git a/packages/turbo-codemod/src/commands/migrate/utils.ts b/packages/turbo-codemod/src/commands/migrate/utils.ts
new file mode 100644
index 0000000..512d78b
--- /dev/null
+++ b/packages/turbo-codemod/src/commands/migrate/utils.ts
@@ -0,0 +1,16 @@
+import { execSync, ExecSyncOptions } from "child_process";
+
+function exec(
+ command: string,
+ opts: ExecSyncOptions,
+ fallback?: string
+): string | undefined {
+ try {
+ const rawResult = execSync(command, opts);
+ return rawResult.toString("utf8").trim();
+ } catch (err) {
+ return fallback || undefined;
+ }
+}
+
+export { exec };