attnmd 0.3.1 → 0.3.3

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.
package/bin/attn.js CHANGED
@@ -12,7 +12,7 @@ const {
12
12
  unlinkSync,
13
13
  writeFileSync,
14
14
  } = require("node:fs");
15
- const { dirname, join } = require("node:path");
15
+ const { dirname, join, resolve } = require("node:path");
16
16
  const { spawnSync } = require("node:child_process");
17
17
  const { homedir } = require("node:os");
18
18
  const { createInterface } = require("node:readline/promises");
@@ -95,7 +95,7 @@ async function main() {
95
95
  return;
96
96
  }
97
97
 
98
- run("/usr/bin/open", [appPath, "--args", ...args]);
98
+ run("/usr/bin/open", [appPath, "--args", ...resolvePathArgs(args)]);
99
99
  }
100
100
 
101
101
  async function resolveAppPath(version) {
@@ -277,7 +277,35 @@ done
277
277
  if [ "$HEADLESS" -eq 1 ]; then
278
278
  exec "$BINARY" "$@"
279
279
  fi
280
- exec /usr/bin/open "$APP_LINK" --args "$@"
280
+ # Resolve the first positional arg to an absolute path since open launches with cwd=/
281
+ RESOLVED_ARGS=()
282
+ PATH_RESOLVED=0
283
+ SKIP_NEXT=0
284
+ for arg in "$@"; do
285
+ if [ "$SKIP_NEXT" -eq 1 ]; then
286
+ RESOLVED_ARGS+=("$arg")
287
+ SKIP_NEXT=0
288
+ continue
289
+ fi
290
+ case "$arg" in
291
+ --eval|--click|--wait-for|--query|--fill|--timeout)
292
+ RESOLVED_ARGS+=("$arg")
293
+ SKIP_NEXT=1
294
+ ;;
295
+ --*)
296
+ RESOLVED_ARGS+=("$arg")
297
+ ;;
298
+ *)
299
+ if [ "$PATH_RESOLVED" -eq 0 ]; then
300
+ RESOLVED_ARGS+=("$(realpath "$arg" 2>/dev/null || echo "$arg")")
301
+ PATH_RESOLVED=1
302
+ else
303
+ RESOLVED_ARGS+=("$arg")
304
+ fi
305
+ ;;
306
+ esac
307
+ done
308
+ exec /usr/bin/open "$APP_LINK" --args "${RESOLVED_ARGS[@]}"
281
309
  `
282
310
  : `#!/usr/bin/env bash
283
311
  set -euo pipefail
@@ -298,6 +326,36 @@ exec "$BINARY" "$@"
298
326
  symlinkSync(installLauncherPath, installLinkPath);
299
327
  }
300
328
 
329
+ function resolvePathArgs(args) {
330
+ // `open` launches the app with cwd=/, so resolve relative paths to absolute
331
+ // before forwarding. The first positional arg (not a flag or flag value) is the path.
332
+ const flagsWithValue = new Set(["--eval", "--click", "--wait-for", "--query", "--fill", "--timeout"]);
333
+ const resolved = [];
334
+ let pathResolved = false;
335
+ let skipNext = false;
336
+ for (const arg of args) {
337
+ if (skipNext) {
338
+ resolved.push(arg);
339
+ skipNext = false;
340
+ continue;
341
+ }
342
+ if (arg.startsWith("--")) {
343
+ resolved.push(arg);
344
+ if (flagsWithValue.has(arg)) {
345
+ skipNext = true;
346
+ }
347
+ continue;
348
+ }
349
+ if (!pathResolved) {
350
+ resolved.push(resolve(arg));
351
+ pathResolved = true;
352
+ } else {
353
+ resolved.push(arg);
354
+ }
355
+ }
356
+ return resolved;
357
+ }
358
+
301
359
  function isHeadlessInvocation(args) {
302
360
  return args.some((arg) => HEADLESS_FLAGS.has(arg));
303
361
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "attnmd",
3
- "version": "0.3.1",
3
+ "version": "0.3.3",
4
4
  "description": "A beautiful markdown viewer that launches from the CLI",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -14,6 +14,12 @@ if (process.env.ATTN_SKIP_DOWNLOAD === "1") {
14
14
  process.exit(0);
15
15
  }
16
16
 
17
+ // On macOS, the .app bundle is managed at runtime in ~/.local/share/attn/apps/
18
+ // and the raw binary is never used. Skip the download.
19
+ if (process.platform === "darwin") {
20
+ process.exit(0);
21
+ }
22
+
17
23
  const { version } = JSON.parse(readFileSync(join(packageDir, "package.json"), "utf8"));
18
24
  const assetSuffix = resolveAssetSuffix(process.platform, process.arch);
19
25