fix: support nix >= 2.19 (#18)

* fix: TypeError when pushing

* fix: compatibility with Nix 2.18
This commit is contained in:
Ryan 2024-01-08 06:00:22 +08:00 committed by GitHub
parent 6689ac7697
commit f75ac4b827
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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);
};