kankaku-tui 0.1.1 → 0.1.2
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/dist/cli.js +22 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import { homedir, hostname } from "node:os";
|
|
4
4
|
import { resolve } from "node:path";
|
|
5
|
+
import { realpathSync } from "node:fs";
|
|
5
6
|
import { pathToFileURL } from "node:url";
|
|
6
7
|
import { render } from "ink";
|
|
7
8
|
import { buildTasks, localDay } from "kankaku/domain";
|
|
@@ -322,7 +323,27 @@ function dashboardActionsDeps(deps, roots) {
|
|
|
322
323
|
},
|
|
323
324
|
};
|
|
324
325
|
}
|
|
325
|
-
|
|
326
|
+
/**
|
|
327
|
+
* Run the entrypoint only when this file is the script Node was started
|
|
328
|
+
* with. npm installs the binary as a symlink (`node_modules/.bin/kankaku ->
|
|
329
|
+
* ../kankaku-tui/dist/cli.js`), so `process.argv[1]` is the link while
|
|
330
|
+
* `import.meta.url` is the real file: compare real paths, or an installed
|
|
331
|
+
* `kankaku` silently does nothing.
|
|
332
|
+
*/
|
|
333
|
+
function isMainModule() {
|
|
334
|
+
const script = process.argv[1];
|
|
335
|
+
if (script === undefined)
|
|
336
|
+
return false;
|
|
337
|
+
let real = script;
|
|
338
|
+
try {
|
|
339
|
+
real = realpathSync(script);
|
|
340
|
+
}
|
|
341
|
+
catch {
|
|
342
|
+
// A missing or unreadable path cannot be this module; fall through with the literal.
|
|
343
|
+
}
|
|
344
|
+
return import.meta.url === pathToFileURL(real).href;
|
|
345
|
+
}
|
|
346
|
+
const isMain = isMainModule();
|
|
326
347
|
if (isMain) {
|
|
327
348
|
const realDeps = {
|
|
328
349
|
homeDir: homedir(),
|