8000 Fix check for package.json path by ncalteen · Pull Request #167 · github/local-action · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix check for package.json path #167

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

Merged
merged 1 commit into from
Mar 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion badges/coverage.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 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": "3.1.0",
"version": "3.1.1",
"type": "module",
"author": "Nick Alteen <ncalteen@github.com>",
"private": false,
Expand Down
10 changes: 7 additions & 3 deletions src/commands/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,19 +119,23 @@ export async function action(): Promise<void> {
// Starting at the target action's entrypoint, find the package.json file.
const dirs = path.dirname(EnvMeta.entrypoint).split(path.sep)
let packageJsonPath
let found = false

// Move up the directory tree until we find a package.json directory.
while (dirs.length > 0) {
packageJsonPath = path.join(process.env.TARGET_ACTION_PATH!, 'package.json')
packageJsonPath = path.resolve(dirs.join(path.sep), 'package.json')

// Check if the current directory has a package.json file.
if (fs.existsSync(packageJsonPath)) break
if (fs.existsSync(packageJsonPath)) {
found = true
break
}

// Move up the directory tree.
dirs.pop()
}

if (dirs.length === 0 || !packageJsonPath)
if (!found || !packageJsonPath)
throw new Error(
'No package.json file found in the action directory or any parent directories.'
)
Expand Down
Loading
0