@comonad/cocode 0.1.9 → 0.1.11

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.
Files changed (2) hide show
  1. package/bin/cocode.mjs +28 -1
  2. package/package.json +1 -1
package/bin/cocode.mjs CHANGED
@@ -199,6 +199,24 @@ async function install(dir, key) {
199
199
  );
200
200
  if (extract.status !== 0) throw new Error(`could not extract ${archive}`);
201
201
  NodeFS.rmSync(file);
202
+ const validate = NodeChildProcess.spawnSync(
203
+ NodePath.join(staging, process.platform === "win32" ? "cocode.exe" : "cocode"),
204
+ ["--version"],
205
+ {
206
+ stdio: ["ignore", "ignore", "pipe"],
207
+ encoding: "utf8",
208
+ timeout: 30_000,
209
+ killSignal: "SIGKILL",
210
+ },
211
+ );
212
+ if (validate.status !== 0) {
213
+ throw executableError(
214
+ key,
215
+ validate.error?.message ||
216
+ validate.stderr?.trim() ||
217
+ `--version exited with ${validate.signal || validate.status}`,
218
+ );
219
+ }
202
220
  NodeFS.writeFileSync(NodePath.join(staging, ".install-complete"), `${version}\n`);
203
221
  publish(staging, dir);
204
222
  } finally {
@@ -270,12 +288,21 @@ async function main() {
270
288
  for (const signal of ["SIGINT", "SIGTERM", "SIGHUP"]) {
271
289
  process.on(signal, () => (ipc || signal !== "SIGINT") && child.kill(signal));
272
290
  }
273
- child.on("error", (error) => fail(error));
291
+ child.on("error", (error) => fail(executableError(key, error.message)));
274
292
  child.on("exit", (code, signal) =>
275
293
  process.exit(code ?? 128 + (NodeOS.constants.signals[signal] || 1)),
276
294
  );
277
295
  }
278
296
 
297
+ function executableError(key, detail) {
298
+ return new Error(
299
+ `could not run CoCode ${version} for ${key}: ${detail}` +
300
+ (process.platform === "linux"
301
+ ? "\nThe Linux release requires glibc; musl-based systems such as Alpine are not supported. Use a glibc-based Linux environment."
302
+ : ""),
303
+ );
304
+ }
305
+
279
306
  function fail(error) {
280
307
  process.stderr.write(`cocode: ${error.message}\n`);
281
308
  process.exit(1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@comonad/cocode",
3
- "version": "0.1.9",
3
+ "version": "0.1.11",
4
4
  "description": "CoCode CLI. Signs you in, then downloads the self-contained executable for this platform.",
5
5
  "license": "MIT",
6
6
  "repository": {