@cerebral-work/lizard 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -23,6 +23,9 @@ export class InstallError extends Error {}
23
23
  export const REPO: string;
24
24
  export const USAGE: string;
25
25
 
26
+ /** The environment minus a GITHUB_TOKEN or GH_TOKEN holding an `op://` reference. */
27
+ export function withoutOpRefs(env: Record<string, string | undefined>): Record<string, string | undefined>;
28
+
26
29
  /** The release asset's Rust target triple for a Node platform and arch. */
27
30
  export function targetFor(platform: string, arch: string): string;
28
31
 
@@ -55,11 +55,24 @@ export function targetFor(platform, arch) {
55
55
  throw new InstallError(`lizard has no build for ${platform}-${arch}.`);
56
56
  }
57
57
 
58
+ // The environment minus a GITHUB_TOKEN or GH_TOKEN that holds a 1Password
59
+ // reference rather than a token. Shells that source op refs export the literal
60
+ // `op://...` placeholder, and gh sends whatever those variables hold as its
61
+ // token, so it would fail instead of using the stored gh login.
62
+ export function withoutOpRefs(env) {
63
+ const out = { ...env };
64
+ for (const k of ["GITHUB_TOKEN", "GH_TOKEN"]) {
65
+ if (out[k]?.startsWith("op://")) delete out[k];
66
+ }
67
+ return out;
68
+ }
69
+
58
70
  // Resolves { status, stdout, stderr, error }. status is the exit code, or null
59
71
  // when the process never ran (error is then set) or was killed by a signal.
60
72
  function run(cmd, args) {
61
73
  return new Promise((done) => {
62
- execFile(cmd, args, { encoding: "utf8", maxBuffer: 64 * 1024 * 1024 }, (err, stdout, stderr) => {
74
+ const options = { encoding: "utf8", maxBuffer: 64 * 1024 * 1024, env: withoutOpRefs(process.env) };
75
+ execFile(cmd, args, options, (err, stdout, stderr) => {
63
76
  if (err && typeof err.code !== "number") {
64
77
  done({ status: null, stdout, stderr, error: err });
65
78
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cerebral-work/lizard",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Installer for lizard, the estate onboarding and control TUI. Downloads the release binary with your own gh login and verifies its SHA-256.",
5
5
  "license": "MIT",
6
6
  "repository": {