From f75ac4b827cc5ce58fbf5d56a958db7aee78879c Mon Sep 17 00:00:00 2001 From: Ryan Date: Mon, 8 Jan 2024 06:00:22 +0800 Subject: [PATCH] fix: support nix >= 2.19 (#18) * fix: TypeError when pushing * fix: compatibility with Nix 2.18 --- src/utils.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/utils.ts b/src/utils.ts index f0218b9..6e1f640 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -6,5 +6,12 @@ export const saveStorePaths = async () => { await exec("sh", ["-c", "nix path-info --all --json > /tmp/store-paths"]); }; export const getStorePaths = async () => { - return (JSON.parse(await readFile("/tmp/store-paths", "utf8")) as { path: string }[]).map((path) => path.path); + const rawStorePaths = JSON.parse(await readFile("/tmp/store-paths", "utf8")) as { path: string }[]; + + // compatibility with Nix 2.18 + if (Array.isArray(rawStorePaths)) { + return rawStorePaths.map((path) => path.path); + }; + + return Object.keys(rawStorePaths); };