@quark-client/quark 1.4.2 → 1.4.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/quark.js +43 -27
  2. package/package.json +6 -6
package/bin/quark.js CHANGED
@@ -3,7 +3,7 @@
3
3
  const os = require('os');
4
4
  const path = require('path');
5
5
  const fs = require('fs');
6
- const { execSync } = require('child_process');
6
+ const { spawnSync } = require('child_process');
7
7
 
8
8
  const platform = os.platform();
9
9
  const arch = os.arch();
@@ -29,37 +29,53 @@ if (!pkgName) {
29
29
  process.exit(1);
30
30
  }
31
31
 
32
- let binPath;
33
- try {
34
- // Try require.resolve first (for local node_modules)
35
- let found = false;
32
+ const exeName = platform === 'win32' ? 'quark.exe' : 'quark';
33
+
34
+ // Locate the platform package directory without importing it as a module
35
+ // (it has no `main`). Resolving its package.json via the normal Node lookup
36
+ // from this file covers npm's nested layout
37
+ // (<main>/node_modules/@quark-client/...) and hoisted/flat layouts. The
38
+ // explicit candidates are a fallback for unusual layouts.
39
+ function findPackageDir() {
36
40
  try {
37
- const pkgPath = require.resolve(pkgName);
38
- binPath = path.join(path.dirname(pkgPath), '..', 'bin', platform === 'win32' ? 'quark.exe' : 'quark');
39
- found = true;
40
- } catch {
41
- // Fall back to looking in npm's global node_modules
42
- const globalNodeModulesParent = path.resolve(__dirname, '../..', '..');
43
- const pkgDir = path.join(globalNodeModulesParent, pkgName);
44
- const pkgJsonPath = path.join(pkgDir, 'package.json');
45
- if (fs.existsSync(pkgJsonPath)) {
46
- binPath = path.join(pkgDir, 'bin', platform === 'win32' ? 'quark.exe' : 'quark');
47
- found = true;
48
- }
49
- }
50
- if (!found) throw new Error('package not found');
51
- } catch (err) {
41
+ return path.dirname(require.resolve(`${pkgName}/package.json`));
42
+ } catch {}
43
+ const mainPkgDir = path.resolve(__dirname, '..');
44
+ const candidates = [
45
+ path.join(mainPkgDir, 'node_modules', pkgName),
46
+ path.resolve(mainPkgDir, '..', '..', pkgName),
47
+ ];
48
+ return candidates.find((d) => fs.existsSync(path.join(d, 'package.json')));
49
+ }
50
+
51
+ const pkgDir = findPackageDir();
52
+ if (!pkgDir) {
52
53
  console.error(`quark: platform package not found (${pkgName})`);
53
54
  console.error('This may happen if npm installed the main package without the matching platform package.');
54
55
  console.error('Try: npm install -g @quark-client/quark@latest');
55
56
  process.exit(1);
56
57
  }
57
58
 
58
- try {
59
- execSync(binPath + ' ' + process.argv.slice(2).join(' '), {
60
- stdio: 'inherit',
61
- shell: platform === 'win32',
62
- });
63
- } catch (err) {
64
- process.exit(err.status || 1);
59
+ const binPath = path.join(pkgDir, 'bin', exeName);
60
+ if (!fs.existsSync(binPath)) {
61
+ console.error(`quark: platform package ${pkgName} is installed at ${pkgDir}, but the executable is missing: ${binPath}`);
62
+ console.error('The installation may be corrupt (e.g. interrupted or blocked by antivirus).');
63
+ console.error('Try: npm uninstall -g @quark-client/quark && npm install -g @quark-client/quark@latest');
64
+ process.exit(1);
65
+ }
66
+
67
+ // Pass arguments straight to the binary: no shell, so spaces, quotes, `&`,
68
+ // `|`, `$` etc. in arguments (URLs, JSON bodies, headers) arrive verbatim.
69
+ const result = spawnSync(binPath, process.argv.slice(2), {
70
+ stdio: 'inherit',
71
+ });
72
+
73
+ if (result.error) {
74
+ console.error(`quark: failed to run ${binPath}: ${result.error.message}`);
75
+ process.exit(1);
76
+ }
77
+ if (result.signal) {
78
+ // Re-raise so the parent shell sees the same signal (e.g. Ctrl+C).
79
+ process.kill(process.pid, result.signal);
65
80
  }
81
+ process.exit(result.status === null ? 1 : result.status);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quark-client/quark",
3
- "version": "1.4.2",
3
+ "version": "1.4.4",
4
4
  "description": "A local-first, keyboard-driven HTTP client",
5
5
  "homepage": "https://github.com/crazy-vedic/Quark",
6
6
  "repository": {
@@ -21,10 +21,10 @@
21
21
  "node": ">=16.0.0"
22
22
  },
23
23
  "optionalDependencies": {
24
- "@quark-client/quark-linux-x64": "1.4.2",
25
- "@quark-client/quark-linux-arm64": "1.4.2",
26
- "@quark-client/quark-darwin-x64": "1.4.2",
27
- "@quark-client/quark-darwin-arm64": "1.4.2",
28
- "@quark-client/quark-win32-x64": "1.4.2"
24
+ "@quark-client/quark-linux-x64": "1.4.4",
25
+ "@quark-client/quark-linux-arm64": "1.4.4",
26
+ "@quark-client/quark-darwin-x64": "1.4.4",
27
+ "@quark-client/quark-darwin-arm64": "1.4.4",
28
+ "@quark-client/quark-win32-x64": "1.4.4"
29
29
  }
30
30
  }