Skip to content

Conversation

@jhheider
Copy link
Contributor

Copy link

Copilot AI left a 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-prefix and no-unversioned-import lint 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,
Copy link

Copilot AI Nov 26, 2025

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]
Suggested change
(_, key, defaultVal) => process.env[key] || defaultVal,
(_, key, defaultVal) => (process.env[key] === undefined || process.env[key] === '') ? defaultVal : process.env[key],

Copilot uses AI. Check for mistakes.
/\$\{([a-zA-Z0-9_]+):\+:\$[a-zA-Z0-9_]+\}/g,
(_, key) => ((v) => v ? `:${v}` : "")(process.env[key]),
)
// handles ${FOO:-bar} > $FOO || "bar"
Copy link

Copilot AI Nov 26, 2025

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 falsy

Or 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)
Suggested change
// handles ${FOO:-bar} > $FOO || "bar"
// handles ${FOO:-bar} - uses default if FOO is unset or falsy

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pkgxdev/dev@v1: Elixir not working without manual ERL_ROOTDIR adjustment

2 participants