klaudio 0.4.0 → 0.4.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/package.json +1 -1
  2. package/src/extractor.js +19 -9
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "klaudio",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "Add sound effects to your coding sessions — play sounds when tasks complete, notifications arrive, and more",
5
5
  "type": "module",
6
6
  "bin": {
package/src/extractor.js CHANGED
@@ -65,29 +65,31 @@ export async function getVgmstreamPath(onProgress) {
65
65
  await mkdir(TOOLS_DIR, { recursive: true });
66
66
 
67
67
  // Download the appropriate release
68
- const releaseUrl = os === "win32"
68
+ const isWindows = os === "win32";
69
+ const releaseUrl = isWindows
69
70
  ? "https://github.com/vgmstream/vgmstream-releases/releases/download/nightly/vgmstream-win64.zip"
70
71
  : os === "darwin"
71
- ? "https://github.com/vgmstream/vgmstream-releases/releases/download/nightly/vgmstream-macos.zip"
72
- : "https://github.com/vgmstream/vgmstream-releases/releases/download/nightly/vgmstream-linux.zip";
72
+ ? "https://github.com/vgmstream/vgmstream-releases/releases/download/nightly/vgmstream-mac-cli.tar.gz"
73
+ : "https://github.com/vgmstream/vgmstream-releases/releases/download/nightly/vgmstream-linux-cli.tar.gz";
73
74
 
74
- const zipPath = join(tmpdir(), "vgmstream.zip");
75
+ const archiveExt = isWindows ? ".zip" : ".tar.gz";
76
+ const archivePath = join(tmpdir(), `vgmstream${archiveExt}`);
75
77
 
76
78
  // Download using Node.js fetch
77
79
  const response = await fetch(releaseUrl, { redirect: "follow" });
78
80
  if (!response.ok) throw new Error(`Failed to download vgmstream: ${response.status}`);
79
81
 
80
- const fileStream = createWriteStream(zipPath);
82
+ const fileStream = createWriteStream(archivePath);
81
83
  await pipeline(response.body, fileStream);
82
84
 
83
85
  if (onProgress) onProgress("Extracting vgmstream-cli...");
84
86
 
85
- // Extract using tar (handles zip on modern systems) or PowerShell on Windows
86
- if (os === "win32") {
87
+ // Extract: PowerShell for Windows, tar for macOS/Linux
88
+ if (isWindows) {
87
89
  await new Promise((resolve, reject) => {
88
90
  execFile("powershell.exe", [
89
91
  "-NoProfile", "-Command",
90
- `Expand-Archive -Path '${zipPath}' -DestinationPath '${TOOLS_DIR}' -Force`,
92
+ `Expand-Archive -Path '${archivePath}' -DestinationPath '${TOOLS_DIR}' -Force`,
91
93
  ], { windowsHide: true }, (err) => {
92
94
  if (err) reject(err);
93
95
  else resolve();
@@ -95,13 +97,21 @@ export async function getVgmstreamPath(onProgress) {
95
97
  });
96
98
  } else {
97
99
  await new Promise((resolve, reject) => {
98
- execFile("unzip", ["-o", zipPath, "-d", TOOLS_DIR], (err) => {
100
+ execFile("tar", ["xzf", archivePath, "-C", TOOLS_DIR], (err) => {
99
101
  if (err) reject(err);
100
102
  else resolve();
101
103
  });
102
104
  });
103
105
  // Make executable
104
106
  try { await chmod(toolPath, 0o755); } catch { /* ignore */ }
107
+ // Remove macOS quarantine attribute so Gatekeeper doesn't block execution
108
+ if (os === "darwin") {
109
+ try {
110
+ await new Promise((resolve) => {
111
+ execFile("xattr", ["-d", "com.apple.quarantine", toolPath], () => resolve());
112
+ });
113
+ } catch { /* ignore — attribute may not exist */ }
114
+ }
105
115
  }
106
116
 
107
117
  // Verify it exists