@hunterzhu/pulse-cli 0.1.8 → 0.1.9

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/bin.js CHANGED
@@ -10,6 +10,7 @@ import { runDoctor } from './commands/doctor.js';
10
10
  import { runSessions } from './commands/sessions.js';
11
11
  import { runResume } from './commands/resume.js';
12
12
  import { runSetup } from './commands/setup.js';
13
+ import { isSameModulePath } from './utils/is-main-module.js';
13
14
  const packageManifest = createRequire(import.meta.url)('../package.json');
14
15
  export const version = packageManifest.version;
15
16
  process.stdout.on('error', (error) => {
@@ -262,7 +263,7 @@ export async function main() {
262
263
  // 默认启动交互式 Ink 界面
263
264
  return runInteractive(options, undefined, undefined, version, parsed.options.resume === true);
264
265
  }
265
- if (process.argv[1] && resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
266
+ if (process.argv[1] && isSameModulePath(process.argv[1], fileURLToPath(import.meta.url))) {
266
267
  main()
267
268
  .then((code) => {
268
269
  process.exitCode = code;
package/dist/config.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { access, chmod, mkdir, readFile, writeFile } from 'node:fs/promises';
2
2
  import { homedir } from 'node:os';
3
- import { dirname, join, resolve } from 'node:path';
3
+ import { dirname, join, resolve, sep } from 'node:path';
4
4
  export const defaultPulseConfig = {
5
5
  providers: {
6
6
  mock: { provider: 'mock', name: 'Mock' },
@@ -58,7 +58,11 @@ export async function ensurePulseUserConfig(path = defaultPulseConfigPath()) {
58
58
  export function expandHome(path) {
59
59
  if (path === undefined)
60
60
  return undefined;
61
- return path === '~' ? homedir() : path.startsWith('~/') ? join(homedir(), path.slice(2)) : path;
61
+ return path === '~' || path === `~${sep}`
62
+ ? homedir()
63
+ : path.startsWith('~/') || (sep === '\\' && path.startsWith('~\\'))
64
+ ? join(homedir(), path.slice(2))
65
+ : path;
62
66
  }
63
67
  function asConfig(value) {
64
68
  if (!value || typeof value !== 'object' || Array.isArray(value))
@@ -0,0 +1,2 @@
1
+ /** Compare resolved entrypoints, following package-manager shims and filesystem symlinks. */
2
+ export declare function isSameModulePath(executablePath: string, modulePath: string, platform?: NodeJS.Platform): boolean;
@@ -0,0 +1,20 @@
1
+ import { realpathSync } from 'node:fs';
2
+ import { resolve, win32 } from 'node:path';
3
+ /** Compare resolved entrypoints, following package-manager shims and filesystem symlinks. */
4
+ export function isSameModulePath(executablePath, modulePath, platform = process.platform) {
5
+ const resolvePath = platform === 'win32' ? win32.resolve : resolve;
6
+ const canonicalize = (path) => {
7
+ const resolved = resolvePath(path);
8
+ try {
9
+ return realpathSync.native(resolved);
10
+ }
11
+ catch {
12
+ return resolved;
13
+ }
14
+ };
15
+ const executable = canonicalize(executablePath);
16
+ const module = canonicalize(modulePath);
17
+ return platform === 'win32'
18
+ ? executable.toLowerCase() === module.toLowerCase()
19
+ : executable === module;
20
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hunterzhu/pulse-cli",
3
- "version": "0.1.8",
3
+ "version": "0.1.9",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/zhuhengtan/Pulse"
@@ -24,7 +24,7 @@
24
24
  "registry": "https://registry.npmjs.org"
25
25
  },
26
26
  "dependencies": {
27
- "@hunterzhu/pulse-server": "0.1.8",
27
+ "@hunterzhu/pulse-server": "0.1.9",
28
28
  "ink": "^7.1.1",
29
29
  "react": "^19.0.0",
30
30
  "ink-spinner": "^5.0.0",