mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-02 20:01:33 +00:00
fix(onboard): ignore blank workspace inputs (#115537)
This commit is contained in:
committed by
GitHub
parent
20c959c227
commit
630e891709
@@ -68,4 +68,21 @@ describe("resolveNonInteractiveWorkspaceDir", () => {
|
||||
|
||||
expect(resolved).toBe(path.join(stateDir, "workspace"));
|
||||
});
|
||||
|
||||
it("ignores blank CLI and configured workspace values", () => {
|
||||
const home = path.join(root, "home");
|
||||
const stateDir = path.join(root, "scratch-state");
|
||||
const resolved = resolveNonInteractiveWorkspaceDir({
|
||||
opts: { workspace: " " },
|
||||
baseConfig: { agents: { defaults: { workspace: "\t" } } },
|
||||
defaultWorkspaceDir: path.join(home, ".openclaw", "workspace"),
|
||||
env: {
|
||||
HOME: home,
|
||||
OPENCLAW_HOME: home,
|
||||
OPENCLAW_STATE_DIR: stateDir,
|
||||
},
|
||||
});
|
||||
|
||||
expect(resolved).toBe(path.join(stateDir, "workspace"));
|
||||
});
|
||||
});
|
||||
|
||||
@@ -18,13 +18,15 @@ export function resolveNonInteractiveWorkspaceDir(params: {
|
||||
env?: NodeJS.ProcessEnv;
|
||||
}) {
|
||||
const env = params.env ?? process.env;
|
||||
const requestedWorkspace = params.opts.workspace?.trim() || undefined;
|
||||
const configuredWorkspace = params.baseConfig.agents?.defaults?.workspace?.trim() || undefined;
|
||||
const workspaceOverride = env.OPENCLAW_WORKSPACE_DIR?.trim() || undefined;
|
||||
const implicitWorkspaceDir = isDefaultStateDir(env)
|
||||
? params.defaultWorkspaceDir
|
||||
: path.join(resolveStateDir(env), "workspace");
|
||||
const raw = (
|
||||
params.opts.workspace ??
|
||||
params.baseConfig.agents?.defaults?.workspace ??
|
||||
requestedWorkspace ??
|
||||
configuredWorkspace ??
|
||||
workspaceOverride ??
|
||||
implicitWorkspaceDir
|
||||
).trim();
|
||||
|
||||
Reference in New Issue
Block a user