Skip to content

fix: module entrypoint guard not portable on Windows #72

@joshjohanning

Description

@joshjohanning

Summary

The module entrypoint guard import.meta.url === \file://${process.argv[1]}`is not portable on Windows, whereprocess.argv[1]uses backslash/drive-letter paths that won't match thefile:///... URL form. This only affects local dev/testing (node src/index.js), not Actions runtime (where nccbundles todist/index.js`).

Current

if (import.meta.url === `file://${process.argv[1]}`) {
  run();
}

Suggested fix

Use path.resolve on both sides to normalize across platforms:

import { fileURLToPath } from 'url';
import * as path from 'path';

const isMainModule = process.argv[1] &&
  path.resolve(fileURLToPath(import.meta.url)) === path.resolve(process.argv[1]);

if (isMainModule) {
  run();
}

Impact

  • Low — only affects local dev/testing, not GitHub Actions runtime
  • Since this is a template, the fix would flow to all derived actions
  • Surfaced by Copilot Code Review on a downstream action

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions