Skip to content

Commit 9d60787

Browse files
authored
Fix import path for win32 platform (#151)
This PR fixes an incorrect import path for win32-based systems to ensure the correct, absolute path is provided to the action import logic. Closes #123
2 parents fda69c9 + aa4943a commit 9d60787

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@github/local-action",
33
"description": "Local Debugging for GitHub Actions",
4-
"version": "2.6.0",
4+
"version": "2.6.1",
55
"type": "module",
66
"author": "Nick Alteen <ncalteen@github.com>",
77
"private": false,

src/commands/run.ts

+11-2
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,15 @@ export async function action(): Promise<void> {
122122
if (dirs.length === 0)
123123
throw new Error('Could not find node_modules directory')
124124

125+
// The entrypoint is OS-specific. On Windows, it has to start with a leading
126+
// slash, then the drive letter, followed by the rest of the path. In both
127+
// cases, the path separators are converted to forward slashes.
128+
/* istanbul ignore next */
129+
const osEntrypoint =
130+
process.platform !== 'win32'
131+
? path.resolve(EnvMeta.entrypoint)
132+
: '/' + path.resolve(EnvMeta.entrypoint.replaceAll(path.sep, '/'))
133+
125134
// Stub the `@actions/toolkit` libraries and run the action. Quibble and
126135
// local-action require a different approach depending on if the called action
127136
// is written in ESM.
@@ -167,7 +176,7 @@ export async function action(): Promise<void> {
167176
)
168177

169178
// ESM actions need to be imported, not required.
170-
const { run } = await import(path.resolve(EnvMeta.entrypoint))
179+
const { run } = await import(osEntrypoint)
171180

172181
// Check if the required path is a function.
173182
if (typeof run !== 'function')
@@ -218,7 +227,7 @@ export async function action(): Promise<void> {
218227
)
219228

220229
// CJS actions need to be required, not imported.
221-
const { run } = require(path.resolve(EnvMeta.entrypoint))
230+
const { run } = require(osEntrypoint)
222231

223232
// Check if the required path is a function.
224233
if (typeof run !== 'function')

0 commit comments

Comments
 (0)