From a28395d9db4778a3cc1a3e09b90b418017f35c53 Mon Sep 17 00:00:00 2001 From: Danila Danko Date: Sat, 30 Mar 2024 17:21:47 +0300 Subject: [PATCH] feat(action): install sqlite3 on macOS if missing --- src/restoreImpl.ts | 3 +++ src/utils/install.ts | 14 ++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 src/utils/install.ts diff --git a/src/restoreImpl.ts b/src/restoreImpl.ts index 27818fda..0e66cc29 100644 --- a/src/restoreImpl.ts +++ b/src/restoreImpl.ts @@ -9,6 +9,7 @@ import { } from "./stateProvider"; import * as utils from "./utils/action"; import * as restore from "./utils/restore"; +import * as install from "./utils/install"; export async function restoreImpl( stateProvider: IStateProvider @@ -33,6 +34,8 @@ export async function restoreImpl( ); } + await install.installSQLite3(); + let restoredKey: string | undefined; let lookedUpKey: string | undefined; const restoredKeys: string[] = []; diff --git a/src/utils/install.ts b/src/utils/install.ts new file mode 100644 index 00000000..4f952c27 --- /dev/null +++ b/src/utils/install.ts @@ -0,0 +1,14 @@ +import { which } from "which"; +import * as inputs from "../inputs"; +import { exec } from "@actions/exec"; +import * as utils from "./action"; + +export async function installSQLite3() { + if (inputs.nix) { + const existsSqlite3 = await which("sqlite3"); + if (!existsSqlite3) { + utils.info("No SQLite 3 found. Installing it."); + exec(`brew install sqlite3`); + } + } +}