-
Notifications
You must be signed in to change notification settings - Fork 743
set activate workspace in .wmill/activeWorkspace in workspace directory #5085
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…ry, can set by workspace switch command
I have read the CLA Document and I hereby sign the CLA You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Looks good to me! Reviewed everything up to cbd81f9 in 17 seconds
More details
- Looked at
35
lines of code in1
files - Skipped
0
files when reviewing. - Skipped posting
3
drafted comments based on config settings.
1. cli/workspace.ts:128
- Draft comment:
Consider usingDeno.lstatSync
instead ofDeno.statSync
to check if '.wmill' is a directory.lstatSync
is more appropriate for checking the existence of a directory or file. - Reason this comment was not posted:
Confidence changes required:50%
The code attempts to check if '.wmill' is a directory using Deno.statSync, which can throw an error if the directory does not exist. This is correctly handled by the try-catch block, but the logic can be improved by using Deno.lstatSync, which is more appropriate for checking the existence of a directory or file.
2. cli/workspace.ts:43
- Draft comment:
Consider handling the case where the '.wmill/activeWorkspace' file might be empty, which could lead to unexpected behavior. - Reason this comment was not posted:
Confidence changes required:50%
The code usesDeno.readTextFile
to read the active workspace file. However, it does not handle the case where the file might be empty, which could lead to unexpected behavior. Adding a check for an empty file would improve robustness.
3. cli/workspace.ts:46
- Draft comment:
Consider handling the case where the 'activeWorkspace' file might be empty, which could lead to unexpected behavior. This is also applicable in the previousDeno.readTextFile
call. - Reason this comment was not posted:
Confidence changes required:50%
The code usesDeno.readTextFile
to read the active workspace file. However, it does not handle the case where the file might be empty, which could lead to unexpected behavior. Adding a check for an empty file would improve robustness. This is applicable in both places whereDeno.readTextFile
is used for reading the active workspace.
Workflow ID: wflow_w9qg5BOXAnbagP4e
You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet
mode, and more.
Thanks for the contribution. It's a nice idea and I did want to do it too. It's lacking a bit of discovery and relying on the existence or not of .wmill which I'm not a fan. I suggest to have an option: --persist-in-folder to the switch command that will indeed write there (and create dir if necessary) but otherwise it's not written there. So it is used by default only if When it's not used because it doesn't exist, a log mention that it's using the global setting because no |
2af98cd
to
90ba65a
Compare
30f0807
to
9c57565
Compare
470be4b
to
3188bee
Compare
edcef56
to
5573d88
Compare
@@ -120,6 +124,14 @@ async function switchC(opts: GlobalOptions, workspaceName: string) { | |||
} | |||
|
|||
export async function setActiveWorkspace(workspaceName: string) { | |||
try { | |||
if (Deno.statSync('.wmill').isDirectory) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The isDirectory
property is actually a method that needs to be invoked with parentheses. This line should be:
if (Deno.statSync('.wmill').isDirectory()) {
Without the parentheses, the condition will evaluate to truthy whenever the method exists on the object, regardless of whether the path is actually a directory.
if (Deno.statSync('.wmill').isDirectory) { | |
if (Deno.statSync('.wmill').isDirectory()) { |
Spotted by Diamond
Is this helpful? React 👍 or 👎 to let us know.
Set activate workspace in .wmill/activeWorkspace in workspace directory by command
wmill workspace switch <workspace>
The workspace activate when switch to the directory automatic.
Important
Prioritize setting and getting active workspace from
.wmill/activeWorkspace
inworkspace.ts
, with fallback to global store.getActiveWorkspaceName()
now prioritizes reading from.wmill/activeWorkspace
before falling back to the global store.setActiveWorkspace()
writes to.wmill/activeWorkspace
if.wmill
directory exists, otherwise writes to global store.getActiveWorkspaceName()
andsetActiveWorkspace()
inworkspace.ts
to handle local and global workspace activation..wmill
directory is not found when setting active workspace.This description was created by
for cbd81f9. It will automatically update as commits are pushed.