oxlint 0.0.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.
Files changed (2) hide show
  1. package/bin/oxlint +67 -0
  2. package/package.json +1 -0
package/bin/oxlint ADDED
@@ -0,0 +1,67 @@
1
+ #!/usr/bin/env node
2
+ const { platform, arch, env, version, release } = process;
3
+
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
+ },
17
+ };
18
+
19
+ const binPath = PLATFORMS?.[platform]?.[arch];
20
+ if (binPath) {
21
+ const result = require("child_process").spawnSync(
22
+ require.resolve(binPath),
23
+ process.argv.slice(2),
24
+ {
25
+ shell: false,
26
+ stdio: "inherit",
27
+ env: {
28
+ ...env,
29
+ JS_RUNTIME_VERSION: version,
30
+ JS_RUNTIME_NAME: release.name,
31
+ NODE_PACKAGE_MANAGER: detectPackageManager(),
32
+ },
33
+ }
34
+ );
35
+
36
+ if (result.error) {
37
+ throw result.error;
38
+ }
39
+
40
+ process.exitCode = result.status;
41
+ } else {
42
+ console.error(
43
+ "The oxlint CLI package doesn't ship with prebuilt binaries for your platform yet. " +
44
+ "You can create an issue at https://github.com/Boshen/oxc/issues for support."
45
+ );
46
+ process.exitCode = 1;
47
+ }
48
+
49
+ /**
50
+ * NPM, Yarn, and other package manager set the `npm_config_user_agent`. It has the following format:
51
+ *
52
+ * ```
53
+ * "npm/8.3.0 node/v16.13.2 win32 x64 workspaces/false
54
+ * ```
55
+ *
56
+ * @returns The package manager string (`npm/8.3.0`) or null if the user agent string isn't set.
57
+ */
58
+ function detectPackageManager() {
59
+ const userAgent = env.npm_config_user_agent;
60
+
61
+ if (userAgent == null) {
62
+ return null;
63
+ }
64
+
65
+ return userAgent.split(" ")[0];
66
+ }
67
+
package/package.json ADDED
@@ -0,0 +1 @@
1
+ {"name":"oxlint","version":"0.0.1","description":"Linter for the JavaScript Oxidation Compiler","keywords":[],"author":"Boshen and oxc contributors","license":"MIT","homepage":"https://github.com/Boshen/oxc","bugs":"https://github.com/Boshen/oxc/issues","repository":{"type":"git","url":"https://github.com/Boshen/oxc","directory":"npm/oxlint"},"bin":"bin/oxlint","funding":{"url":"https://github.com/sponsors/Boshen"},"engines":{"node":">=14.*"},"files":["bin/oxlint"],"optionalDependencies":{"@oxlint/win32-x64":"0.0.1","@oxlint/win32-arm64":"0.0.1","@oxlint/darwin-x64":"0.0.1","@oxlint/darwin-arm64":"0.0.1","@oxlint/linux-x64":"0.0.1","@oxlint/linux-arm64":"0.0.1"}}