pikiloom 0.4.2 → 0.4.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/dist/cli/main.js +15 -4
- package/package.json +1 -1
package/dist/cli/main.js
CHANGED
|
@@ -319,9 +319,10 @@ Docs: https://github.com/xiaotonng/pikiloom
|
|
|
319
319
|
/**
|
|
320
320
|
* For a fresh CLI launch (not a daemon-managed child), persist the working
|
|
321
321
|
* directory into setting.json so the bot defaults to where the user invoked
|
|
322
|
-
* the command.
|
|
323
|
-
*
|
|
324
|
-
* the
|
|
322
|
+
* the command. An explicit `-w` always wins and is saved. Without `-w`, a
|
|
323
|
+
* previously saved workdir (including one chosen later in the dashboard) is
|
|
324
|
+
* kept as-is; we only fall back to the launch cwd on first run, when nothing
|
|
325
|
+
* has been saved yet, so relaunching never silently reverts the workdir.
|
|
325
326
|
*/
|
|
326
327
|
function persistWorkdir(args, userConfig) {
|
|
327
328
|
if (process.env.PIKILOOM_DAEMON_CHILD)
|
|
@@ -331,7 +332,17 @@ function persistWorkdir(args, userConfig) {
|
|
|
331
332
|
// whatever the user previously chose interactively.
|
|
332
333
|
if (process.env[FROM_LAUNCHD_ENV])
|
|
333
334
|
return userConfig;
|
|
334
|
-
|
|
335
|
+
// An explicit `-w` is a deliberate choice and always wins. Without it, a
|
|
336
|
+
// workdir the user already saved (e.g. picked in the dashboard via
|
|
337
|
+
// `/api/switch-workdir`) must survive relaunch — otherwise every fresh
|
|
338
|
+
// `npx pikiloom` silently reverts the workdir to its launch cwd. Only fall
|
|
339
|
+
// back to cwd on first run, when nothing has been saved yet.
|
|
340
|
+
const explicitWorkdir = typeof args.workdir === 'string' && args.workdir.trim()
|
|
341
|
+
? args.workdir.trim()
|
|
342
|
+
: '';
|
|
343
|
+
if (!explicitWorkdir && userConfig.workdir)
|
|
344
|
+
return userConfig;
|
|
345
|
+
const nextWorkdir = path.resolve(explicitWorkdir || process.cwd());
|
|
335
346
|
if (userConfig.workdir === nextWorkdir)
|
|
336
347
|
return userConfig;
|
|
337
348
|
updateUserConfig({ workdir: nextWorkdir });
|