-
Notifications
You must be signed in to change notification settings - Fork 10
fix ERL_ROOTDIR issues #57
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
preserve behavior; should probably just version. see: https://docs.deno.com/lint/rules/no-unversioned-import/
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.
Pull request overview
This PR fixes ERL_ROOTDIR environment variable handling issues by adding support for bash-style default value syntax (${FOO:-bar}) in the GitHub Actions environment variable parser. The changes ensure that environment variables can specify fallback values, which is particularly important for Erlang's ERL_ROOTDIR configuration.
- Adds regex pattern to handle
${FOO:-bar}syntax (use default if variable is unset or falsy) - Excludes
no-import-prefixandno-unversioned-importlint rules for Deno imports
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| action.js | Adds support for bash-style default value syntax (${FOO:-bar}) in environment variable substitution |
| deno.json | Excludes two Deno-specific lint rules to accommodate existing import patterns |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // handles ${FOO:-bar} > $FOO || "bar" | ||
| .replaceAll( | ||
| /\$\{([a-zA-Z0-9_]+):-([^}]*)\}/g, | ||
| (_, key, defaultVal) => process.env[key] || defaultVal, |
Copilot
AI
Nov 26, 2025
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 use of || operator here may not correctly handle environment variables that are set to an empty string. In bash, ${FOO:-bar} uses the default value when FOO is unset or empty, but process.env[key] || defaultVal will use the default value for any falsy value including 0 or false.
Consider using ?? defaultVal instead to match bash behavior more closely, or explicitly check for undefined/null:
(_, key, defaultVal) => (process.env[key] ?? defaultVal)However, note that even ?? won't treat empty strings the same as bash does. For exact bash parity, you'd need:
(_, key, defaultVal) => (process.env[key] === undefined || process.env[key] === '') ? defaultVal : process.env[key]| (_, key, defaultVal) => process.env[key] || defaultVal, | |
| (_, key, defaultVal) => (process.env[key] === undefined || process.env[key] === '') ? defaultVal : process.env[key], |
| /\$\{([a-zA-Z0-9_]+):\+:\$[a-zA-Z0-9_]+\}/g, | ||
| (_, key) => ((v) => v ? `:${v}` : "")(process.env[key]), | ||
| ) | ||
| // handles ${FOO:-bar} > $FOO || "bar" |
Copilot
AI
Nov 26, 2025
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 comment states ${FOO:-bar} > $FOO || "bar" but this is misleading. In bash, ${FOO:-bar} means "use $FOO if set and non-empty, otherwise use bar". The implementation uses the JavaScript || operator which has different semantics—it will also use the default for falsy values like 0, false, or empty string (though empty string matches bash behavior).
Consider updating the comment to be more accurate:
// handles ${FOO:-bar} - uses default if FOO is unset or falsyOr if you want to strictly match bash behavior (use default only when unset or empty):
// handles ${FOO:-bar} - uses default if FOO is unset or empty (bash-style)| // handles ${FOO:-bar} > $FOO || "bar" | |
| // handles ${FOO:-bar} - uses default if FOO is unset or falsy |
see #56 (comment)