-
Notifications
You must be signed in to change notification settings - Fork 345
DevContainer commands now default the workspace folder to the current directory if not specified. #1104
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
chrmarti
left a comment
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.
Great, thanks! Left a few comments.
| 'container-data-folder': { type: 'string', description: 'Container data folder where user data inside the container will be stored.' }, | ||
| 'container-system-data-folder': { type: 'string', description: 'Container system data folder where system data inside the container will be stored.' }, | ||
| 'workspace-folder': { type: 'string', description: 'Workspace folder path. The devcontainer.json will be looked up relative to this path.' }, | ||
| 'workspace-folder': { type: 'string', description: 'Workspace folder path. The devcontainer.json will be looked up relative to this path. If not provided, defaults to the current directory.' }, |
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.
Mention --container-id and --id-label like in the descriptions of the other commands.
| "name": "@devcontainers/cli", | ||
| "description": "Dev Containers CLI", | ||
| "version": "0.80.2", | ||
| "version": "0.80.3", |
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.
Let's make it 0.81.0 and list the improvement in the changelog.
| .options({ | ||
| 'log-level': { choices: ['error' as 'error', 'info' as 'info', 'debug' as 'debug', 'trace' as 'trace'], default: 'error' as 'error', description: 'Log level.' }, | ||
| 'workspace-folder': { type: 'string', description: 'Workspace folder to use for the configuration.', demandOption: true }, | ||
| 'workspace-folder': { type: 'string', description: 'Workspace folder to use for the configuration.' }, |
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.
Mention using the current folder when not provided like in the other descriptions.
| return y | ||
| .options({ | ||
| 'workspace-folder': { type: 'string', alias: 'w', demandOption: true, default: '.', description: 'Target workspace folder to apply Template' }, | ||
| 'workspace-folder': { type: 'string', alias: 'w', default: '.', description: 'Target workspace folder to apply Template' }, |
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.
Mention the default like in the other descriptions. Maybe omit default: '.', though I'm not sure that shows anywhere (like in the help text).
| const absoluteCliPath = `npx --prefix ${absoluteTmpPath} devcontainer`; | ||
|
|
||
| // First check if the config file exists | ||
| const configExists = require('fs').existsSync('.devcontainer/devcontainer.json') || |
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.
Use import at the top instead of require.
| jsonOutput = JSON.parse(result.stdout.trim()); | ||
| } catch (parseError) { | ||
| // If direct parsing fails, try extracting JSON from mixed output | ||
| const lines = result.stdout.split('\n'); |
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.
This seems to be a bug in the output. Let's not block on this, something to look into in the future.
Fixes: #1069
Issue summary:
This PR enhances the user experience by automatically defaulting the [--workspace-folder] parameter to the current working directory when it is not explicitly specified. The following DevContainer CLI commands will now use the current working directory as the default workspace folder if [--workspace-folder] is omitted:
Test cases is implemented for all these commands