Browse Source

fix(cli): align preview launcher packaging

Dax Raad 2 months ago
parent
commit
e43401f3c5
2 changed files with 20 additions and 1 deletions
  1. 19 0
      packages/cli/bin/lildax.cjs
  2. 1 1
      packages/cli/script/publish.ts

+ 19 - 0
packages/cli/bin/lildax.cjs

@@ -54,6 +54,25 @@ function supportsAvx2() {
       return false
     }
   }
+  if (platform === "windows") {
+    const command =
+      '(Add-Type -MemberDefinition "[DllImport(""kernel32.dll"")] public static extern bool IsProcessorFeaturePresent(int ProcessorFeature);" -Name Kernel32 -Namespace Win32 -PassThru)::IsProcessorFeaturePresent(40)'
+    for (const executable of ["powershell.exe", "pwsh.exe", "pwsh", "powershell"]) {
+      try {
+        const result = childProcess.spawnSync(executable, ["-NoProfile", "-NonInteractive", "-Command", command], {
+          encoding: "utf8",
+          timeout: 3000,
+          windowsHide: true,
+        })
+        if (result.status !== 0) continue
+        const output = (result.stdout || "").trim().toLowerCase()
+        if (output === "true" || output === "1") return true
+        if (output === "false" || output === "0") return false
+      } catch {
+        continue
+      }
+    }
+  }
   return false
 }
 

+ 1 - 1
packages/cli/script/publish.ts

@@ -14,7 +14,7 @@ async function published(name: string, version: string) {
 async function publish(dir: string, name: string, version: string) {
   if (process.platform !== "win32") await $`chmod -R 755 .`.cwd(dir)
   if (await published(name, version)) return console.log(`already published ${name}@${version}`)
-  await $`npm pack`.cwd(dir)
+  await $`bun pm pack`.cwd(dir)
   await $`npm publish *.tgz --access public --tag ${Script.channel}`.cwd(dir)
 }