Skip to content

Commit 63bf070

Browse files
committed
Fix CLI startup through symlinks
1 parent 51d36d3 commit 63bf070

3 files changed

Lines changed: 23 additions & 7 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ This project aims to follow [Semantic Versioning](https://semver.org/). Breaking
66

77
## [Unreleased]
88

9-
### Added
9+
## [0.1.1] - 2026-05-07
10+
11+
### Fixed
1012

11-
- Expanded public documentation for README, authentication, examples, troubleshooting, and contribution workflow.
12-
- Generated command reference now displays actual shell command syntax.
13+
- Fixed CLI startup when installed through package-manager symlinks such as Homebrew and npm global bins.
1314

1415
## [0.1.0] - 2026-05-06
1516

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@mocito/raindrop-cli",
3-
"version": "0.1.0",
3+
"version": "0.1.1",
44
"description": "Agent-friendly CLI for Raindrop.io",
55
"type": "module",
66
"repository": {

src/cli.ts

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
#!/usr/bin/env node
22
import { Command } from "commander";
33
import { execFile } from "node:child_process";
4-
import { openAsBlob } from "node:fs";
4+
import { openAsBlob, readFileSync, realpathSync } from "node:fs";
55
import { createServer } from "node:http";
66
import { appendFile, writeFile, mkdir, readFile } from "node:fs/promises";
77
import { dirname } from "node:path";
8+
import { fileURLToPath } from "node:url";
89
import { ApiClient, delay } from "./core/client.js";
910
import {
1011
clearProfileToken,
@@ -58,7 +59,9 @@ import {
5859
validateLimit,
5960
} from "./core/validators.js";
6061

61-
const version = "0.1.0";
62+
const version = JSON.parse(
63+
readFileSync(new URL("../package.json", import.meta.url), "utf8"),
64+
).version as string;
6265

6366
type Handler<T extends unknown[] = unknown[]> = (...args: T) => Promise<void>;
6467

@@ -3016,6 +3019,18 @@ function agentCommands(): Record<string, any> {
30163019
return out;
30173020
}
30183021

3019-
if (import.meta.url === `file://${process.argv[1]}`) {
3022+
function isMainModule(): boolean {
3023+
if (!process.argv[1]) return false;
3024+
try {
3025+
return (
3026+
realpathSync(fileURLToPath(import.meta.url)) ===
3027+
realpathSync(process.argv[1])
3028+
);
3029+
} catch {
3030+
return false;
3031+
}
3032+
}
3033+
3034+
if (isMainModule()) {
30203035
await buildProgram().parseAsync(process.argv);
30213036
}

0 commit comments

Comments
 (0)