oxlint 0.2.3 → 0.2.4

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/oxlint +109 -18
  2. package/package.json +1 -1
package/bin/oxlint CHANGED
@@ -1,22 +1,114 @@
1
1
  #!/usr/bin/env node
2
- const { platform, arch, env, version, release } = process;
3
2
 
4
- const PLATFORMS = {
5
- win32: {
6
- x64: "@oxlint/win32-x64/oxlint.exe",
7
- arm64: "@oxlint/win32-arm64/oxlint.exe",
8
- },
9
- darwin: {
10
- x64: "@oxlint/darwin-x64/oxlint",
11
- arm64: "@oxlint/darwin-arm64/oxlint",
12
- },
13
- linux: {
14
- x64: "@oxlint/linux-x64/oxlint",
15
- arm64: "@oxlint/linux-arm64/oxlint",
16
- },
3
+ const isMusl = () => {
4
+ let musl = false;
5
+ if (process.platform === "linux") {
6
+ musl = isMuslFromFilesystem();
7
+ if (musl === null) {
8
+ musl = isMuslFromReport();
9
+ }
10
+ if (musl === null) {
11
+ musl = isMuslFromChildProcess();
12
+ }
13
+ }
14
+ return musl;
15
+ };
16
+
17
+ const isFileMusl = (f) => f.includes("libc.musl-") || f.includes("ld-musl-");
18
+
19
+ const isMuslFromFilesystem = () => {
20
+ const { readFileSync } = require("fs");
21
+ try {
22
+ return readFileSync("/usr/bin/ldd", "utf-8").includes("musl");
23
+ } catch {
24
+ return null;
25
+ }
26
+ };
27
+
28
+ const isMuslFromReport = () => {
29
+ const report =
30
+ typeof process.report.getReport === "function"
31
+ ? process.report.getReport()
32
+ : null;
33
+ if (!report) {
34
+ return null;
35
+ }
36
+ if (report.header && report.header.glibcVersionRuntime) {
37
+ return false;
38
+ }
39
+ if (Array.isArray(report.sharedObjects)) {
40
+ if (report.sharedObjects.some(isFileMusl)) {
41
+ return true;
42
+ }
43
+ }
44
+ return false;
45
+ };
46
+
47
+ const isMuslFromChildProcess = () => {
48
+ try {
49
+ return require("child_process")
50
+ .execSync("ldd --version", { encoding: "utf8" })
51
+ .includes("musl");
52
+ } catch (e) {
53
+ // If we reach this case, we don't know if the system is musl or not, so is better to just fallback to false
54
+ return false;
55
+ }
17
56
  };
18
57
 
19
- const binPath = PLATFORMS?.[platform]?.[arch];
58
+ const { platform, arch, env, version, release } = process;
59
+
60
+ let binPath;
61
+
62
+ switch (platform) {
63
+ case "win32": {
64
+ switch (arch) {
65
+ case "x64": {
66
+ binPath = "@oxlint/win32-x64/oxlint.exe";
67
+ break;
68
+ }
69
+ case "arm64": {
70
+ binPath = "@oxlint/win32-arm64/oxlint.exe";
71
+ break;
72
+ }
73
+ }
74
+ break;
75
+ }
76
+ case "darwin": {
77
+ switch (arch) {
78
+ case "x64": {
79
+ binPath = "@oxlint/darwin-x64/oxlint";
80
+ break;
81
+ }
82
+ case "arm64": {
83
+ binPath = "@oxlint/darwin-arm64/oxlint";
84
+ break;
85
+ }
86
+ }
87
+ break;
88
+ }
89
+ case "linux": {
90
+ switch (arch) {
91
+ case "x64": {
92
+ if (isMusl()) {
93
+ binPath = "@oxlint/linux-x64-musl/oxlint";
94
+ } else {
95
+ binPath = "@oxlint/linux-x64-gnu/oxlint";
96
+ }
97
+ break;
98
+ }
99
+ case "arm64": {
100
+ if (isMusl()) {
101
+ binPath = "@oxlint/linux-arm64-musl/oxlint";
102
+ } else {
103
+ binPath = "@oxlint/linux-arm64-gnu/oxlint";
104
+ }
105
+ break;
106
+ }
107
+ }
108
+ break;
109
+ }
110
+ }
111
+
20
112
  if (binPath) {
21
113
  const result = require("child_process").spawnSync(
22
114
  require.resolve(binPath),
@@ -30,7 +122,7 @@ if (binPath) {
30
122
  JS_RUNTIME_NAME: release.name,
31
123
  NODE_PACKAGE_MANAGER: detectPackageManager(),
32
124
  },
33
- }
125
+ },
34
126
  );
35
127
 
36
128
  if (result.error) {
@@ -41,7 +133,7 @@ if (binPath) {
41
133
  } else {
42
134
  console.error(
43
135
  "The oxlint CLI package doesn't ship with prebuilt binaries for your platform yet. " +
44
- "You can create an issue at https://github.com/oxc-project/oxc/issues for support."
136
+ "You can create an issue at https://github.com/oxc-project/oxc/issues for support.",
45
137
  );
46
138
  process.exitCode = 1;
47
139
  }
@@ -64,4 +156,3 @@ function detectPackageManager() {
64
156
 
65
157
  return userAgent.split(" ")[0];
66
158
  }
67
-
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name":"oxlint","version":"0.2.3","description":"Linter for the JavaScript Oxidation Compiler","keywords":[],"author":"Boshen and oxc contributors","license":"MIT","homepage":"https://oxc-project.github.io","bugs":"https://github.com/oxc-project/oxc/issues","repository":{"type":"git","url":"https://github.com/oxc-project/oxc","directory":"npm/oxlint"},"bin":"bin/oxlint","funding":{"url":"https://github.com/sponsors/Boshen"},"engines":{"node":">=14.*"},"files":["bin/oxlint","README.md"],"optionalDependencies":{"@oxlint/win32-x64":"0.2.3","@oxlint/win32-arm64":"0.2.3","@oxlint/linux-x64-gnu":"0.2.3","@oxlint/linux-arm64-gnu":"0.2.3","@oxlint/linux-x64-musl":"0.2.3","@oxlint/linux-arm64-musl":"0.2.3","@oxlint/darwin-x64":"0.2.3","@oxlint/darwin-arm64":"0.2.3"}}
1
+ {"name":"oxlint","version":"0.2.4","description":"Linter for the JavaScript Oxidation Compiler","keywords":[],"author":"Boshen and oxc contributors","license":"MIT","homepage":"https://oxc-project.github.io","bugs":"https://github.com/oxc-project/oxc/issues","repository":{"type":"git","url":"https://github.com/oxc-project/oxc","directory":"npm/oxlint"},"bin":"bin/oxlint","funding":{"url":"https://github.com/sponsors/Boshen"},"engines":{"node":">=14.*"},"files":["bin/oxlint","README.md"],"optionalDependencies":{"@oxlint/win32-x64":"0.2.4","@oxlint/win32-arm64":"0.2.4","@oxlint/linux-x64-gnu":"0.2.4","@oxlint/linux-arm64-gnu":"0.2.4","@oxlint/linux-x64-musl":"0.2.4","@oxlint/linux-arm64-musl":"0.2.4","@oxlint/darwin-x64":"0.2.4","@oxlint/darwin-arm64":"0.2.4"}}