devcontainer-rs 0.0.33 → 0.0.34

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/launcher.js +39 -13
  2. package/package.json +5 -2
package/launcher.js CHANGED
@@ -4,6 +4,26 @@ const { execFileSync, spawn } = require("node:child_process");
4
4
 
5
5
  const runtimeConfig = require("./runtime-config");
6
6
 
7
+ function outputText(value) {
8
+ if (!value) {
9
+ return "";
10
+ }
11
+ if (Buffer.isBuffer(value)) {
12
+ return value.toString("utf8");
13
+ }
14
+ return String(value);
15
+ }
16
+
17
+ function parseLibcOutput(output) {
18
+ if (/musl/i.test(output)) {
19
+ return "musl";
20
+ }
21
+ if (/glibc|gnu libc|gnu c library/i.test(output)) {
22
+ return "gnu";
23
+ }
24
+ return null;
25
+ }
26
+
7
27
  function detectLibc(system = {}) {
8
28
  if ((system.platform || process.platform) !== "linux") {
9
29
  return null;
@@ -13,11 +33,12 @@ function detectLibc(system = {}) {
13
33
  return system.libc;
14
34
  }
15
35
 
16
- if (process.env.DEVCONTAINER_RS_LIBC) {
17
- return process.env.DEVCONTAINER_RS_LIBC;
36
+ const env = system.env || process.env;
37
+ if (env.DEVCONTAINER_RS_LIBC) {
38
+ return env.DEVCONTAINER_RS_LIBC;
18
39
  }
19
40
 
20
- const report = process.report;
41
+ const report = system.report || process.report;
21
42
  if (report && typeof report.getReport === "function") {
22
43
  const glibcVersion = report.getReport()?.header?.glibcVersionRuntime;
23
44
  if (glibcVersion) {
@@ -25,31 +46,36 @@ function detectLibc(system = {}) {
25
46
  }
26
47
  }
27
48
 
49
+ const runCommand = system.execFileSync || execFileSync;
28
50
  try {
29
- const output = execFileSync("getconf", ["GNU_LIBC_VERSION"], {
51
+ const output = runCommand("getconf", ["GNU_LIBC_VERSION"], {
30
52
  encoding: "utf8",
31
53
  stdio: ["ignore", "pipe", "ignore"],
32
54
  });
33
- if (/glibc/i.test(output)) {
34
- return "gnu";
55
+ const libc = parseLibcOutput(output);
56
+ if (libc) {
57
+ return libc;
35
58
  }
36
59
  } catch (_error) {
37
60
  // fall through to ldd parsing
38
61
  }
39
62
 
40
63
  try {
41
- const output = execFileSync("ldd", ["--version"], {
64
+ const output = runCommand("ldd", ["--version"], {
42
65
  encoding: "utf8",
43
66
  stdio: ["ignore", "pipe", "pipe"],
44
67
  });
45
- if (/musl/i.test(output)) {
46
- return "musl";
68
+ const libc = parseLibcOutput(output);
69
+ if (libc) {
70
+ return libc;
47
71
  }
48
- if (/glibc|gnu libc|gnu c library/i.test(output)) {
49
- return "gnu";
72
+ } catch (error) {
73
+ const libc = parseLibcOutput(
74
+ `${outputText(error.stdout)}\n${outputText(error.stderr)}`,
75
+ );
76
+ if (libc) {
77
+ return libc;
50
78
  }
51
- } catch (_error) {
52
- // fall through to the default below
53
79
  }
54
80
 
55
81
  return "gnu";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "devcontainer-rs",
3
- "version": "0.0.33",
3
+ "version": "0.0.34",
4
4
  "description": "Rust-native devcontainer CLI wrapper package",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -23,6 +23,9 @@
23
23
  "runtime-config.js"
24
24
  ],
25
25
  "optionalDependencies": {
26
- "@devcontainer-rs/devcontainer-darwin-arm64": "0.0.33"
26
+ "@devcontainer-rs/devcontainer-darwin-x64": "0.0.34",
27
+ "@devcontainer-rs/devcontainer-darwin-arm64": "0.0.34",
28
+ "@devcontainer-rs/devcontainer-linux-x64-gnu": "0.0.34",
29
+ "@devcontainer-rs/devcontainer-linux-x64-musl": "0.0.34"
27
30
  }
28
31
  }