chad-code 1.3.8 → 1.3.9

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/chad-code +19 -17
  2. package/package.json +1 -1
package/bin/chad-code CHANGED
@@ -1,12 +1,13 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- const childProcess = require("child_process")
4
- const fs = require("fs")
5
- const path = require("path")
6
- const os = require("os")
3
+ import { spawnSync } from "child_process"
4
+ import { existsSync, readdirSync, realpathSync } from "fs"
5
+ import { dirname, join } from "path"
6
+ import { platform as osPlatform, arch as osArch } from "os"
7
+ import { fileURLToPath } from "url"
7
8
 
8
9
  function run(target) {
9
- const result = childProcess.spawnSync(target, process.argv.slice(2), {
10
+ const result = spawnSync(target, process.argv.slice(2), {
10
11
  stdio: "inherit",
11
12
  })
12
13
  if (result.error) {
@@ -22,8 +23,9 @@ if (envPath) {
22
23
  run(envPath)
23
24
  }
24
25
 
25
- const scriptPath = fs.realpathSync(__filename)
26
- const scriptDir = path.dirname(scriptPath)
26
+ const __filename = fileURLToPath(import.meta.url)
27
+ const scriptPath = realpathSync(__filename)
28
+ const scriptDir = dirname(scriptPath)
27
29
 
28
30
  const platformMap = {
29
31
  darwin: "darwin",
@@ -36,13 +38,13 @@ const archMap = {
36
38
  arm: "arm",
37
39
  }
38
40
 
39
- let platform = platformMap[os.platform()]
41
+ let platform = platformMap[osPlatform()]
40
42
  if (!platform) {
41
- platform = os.platform()
43
+ platform = osPlatform()
42
44
  }
43
- let arch = archMap[os.arch()]
45
+ let arch = archMap[osArch()]
44
46
  if (!arch) {
45
- arch = os.arch()
47
+ arch = osArch()
46
48
  }
47
49
  const base = "chad-code-" + platform + "-" + arch
48
50
  const binary = platform === "windows" ? "chad-code.exe" : "chad-code"
@@ -50,20 +52,20 @@ const binary = platform === "windows" ? "chad-code.exe" : "chad-code"
50
52
  function findBinary(startDir) {
51
53
  let current = startDir
52
54
  for (;;) {
53
- const modules = path.join(current, "node_modules")
54
- if (fs.existsSync(modules)) {
55
- const entries = fs.readdirSync(modules)
55
+ const modules = join(current, "node_modules")
56
+ if (existsSync(modules)) {
57
+ const entries = readdirSync(modules)
56
58
  for (const entry of entries) {
57
59
  if (!entry.startsWith(base)) {
58
60
  continue
59
61
  }
60
- const candidate = path.join(modules, entry, "bin", binary)
61
- if (fs.existsSync(candidate)) {
62
+ const candidate = join(modules, entry, "bin", binary)
63
+ if (existsSync(candidate)) {
62
64
  return candidate
63
65
  }
64
66
  }
65
67
  }
66
- const parent = path.dirname(current)
68
+ const parent = dirname(current)
67
69
  if (parent === current) {
68
70
  return
69
71
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
- "version": "1.3.8",
3
+ "version": "1.3.9",
4
4
  "name": "chad-code",
5
5
  "type": "module",
6
6
  "license": "MIT",