Skip to content

Commit

Permalink
Upgrade to require Node.js 20.6.0
Browse files Browse the repository at this point in the history
This allows the quibble ESM loader to be included automatically when calling the action (preventing it from needing to be installed in the local Node environment).
  • Loading branch information
ncalteen committed Aug 29, 2024
1 parent 5d37e4c commit 3a0ee8e
Showing 5 changed files with 44 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .node-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20.5.1
20.6.0
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -14,6 +14,12 @@ actions can be run directly on your workstation.
>
> This tool currently only supports JavaScript and TypeScript actions!
## v2 Changes

As of version `2.0.0`, the `local-action` tool has been updated to require
**Node.js v20.6.0** or higher. This is necessary to support ESM loaders to
override dependencies in the GitHub Actions Toolkit.

## v1 Changes

With the release of `v1.0.0`, there was a need to switch from
50 changes: 30 additions & 20 deletions bin/local-action.js
Original file line number Diff line number Diff line change
@@ -39,29 +39,39 @@ function entrypoint() {
? `${process.env.NODE_OPTIONS} --require ${bootstrapPath}`
: `--require ${bootstrapPath}`

// Disable experimental warnings.
process.env.NODE_NO_WARNINGS = 1

// Start building the command to run local-action.
let command = `npx tsx --loader=quibble "${path.join(packagePath, 'src', 'index.ts')}"`
let command = `npx tsx "${path.join(packagePath, 'src', 'index.ts')}"`

// If there are no input arguments, or the only argument is the help flag,
// display the help message.
if (
process.argv.length === 2 ||
['--help', '-h'].includes(process.argv[2])
) {
command += ` --help`

// Run the command.
execSync(command, { stdio: 'inherit' })
return
}

// Process the input arguments.
if (process.argv.length === 2) {
// No arguments...display the help message.
command += ' --help'
} else {
// Iterate over the arguments and build the command.
for (const arg of process.argv.slice(2)) {
// If the argument is a directory and TARGET_ACTION_PATH is not set, set
// it to the absolute path of the directory. The first directory is the
// target action path.
if (
!process.env.TARGET_ACTION_PATH &&
fs.existsSync(path.resolve(arg)) &&
fs.lstatSync(path.resolve(arg)).isDirectory()
)
process.env.TARGET_ACTION_PATH = path.resolve(arg)
// Iterate over the arguments and build the command.
for (const arg of process.argv.slice(2)) {
// If the argument is a directory and TARGET_ACTION_PATH is not set, set
// it to the absolute path of the directory. The first directory is the
// target action path.
if (
!process.env.TARGET_ACTION_PATH &&
fs.existsSync(path.resolve(arg)) &&
fs.lstatSync(path.resolve(arg)).isDirectory()
)
process.env.TARGET_ACTION_PATH = path.resolve(arg)

// Append the argument to the command.
command += ` ${arg}`
}
// Append the argument to the command.
command += ` ${arg}`
}

// Run the command.
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@github/local-action",
"description": "Local Debugging for GitHub Actions",
"version": "2.0.0",
"version": "2.1.0",
"type": "module",
"author": "Nick Alteen <[email protected]>",
"private": false,

0 comments on commit 3a0ee8e

Please sign in to comment.