-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
closes #4
- Loading branch information
Showing
3 changed files
with
10 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,10 @@ | ||
import { exec } from "@actions/exec"; | ||
import { Writable } from "node:stream"; | ||
|
||
class StringStream extends Writable { | ||
chunks: Buffer[] = []; | ||
|
||
_write(chunk: WithImplicitCoercion<ArrayBuffer | SharedArrayBuffer>, _enc: unknown, next: () => unknown) { | ||
this.chunks.push(Buffer.from(chunk)); | ||
next(); | ||
} | ||
|
||
string() { | ||
return Buffer.concat(this.chunks).toString("utf-8"); | ||
} | ||
} | ||
import { readFile } from "node:fs/promises"; | ||
|
||
export const saveStorePaths = async () => { | ||
await exec("sh", ["-c", "nix path-info --all --json > /tmp/store-paths"]); | ||
}; | ||
export const getStorePaths = async () => { | ||
const outStream = new StringStream(); | ||
await exec("nix", ["path-info", "--all"], { outStream }); | ||
const paths = outStream.string().split("\n").filter(Boolean); | ||
|
||
return paths; | ||
return JSON.parse(await readFile("/tmp/store-paths", "utf8")).map((path) => path.path); | ||
}; |