Skip to content

Commit

Permalink
feat: custom package.json location (#297)
Browse files Browse the repository at this point in the history
  • Loading branch information
esbakker authored Jun 10, 2024
1 parent 3d69646 commit 9b7db69
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 6 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,19 @@ Example invalid package.json this will prevent:

## Other Inputs

Specify `package-json-location` to specify another location for the package.json to validate. Defaults to `./package.json`.

```yaml
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: ExpediaGroup/package-json-validator@v1
with:
rules: ranges
package-json-location: ./project/package.json
```

Specify `dependency-types` to denote which type of package.json dependencies you wish to validate. Valid options include `dependencies`, `devDependencies`, `peerDependencies`, and `optionalDependencies`. Defaults to `dependencies`.

```yaml
Expand Down
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ inputs:
ignore-resolutions-until:
description: 'Date string to skip validation for resolutions field for a specific amount of time.'
required: false
package-json-location:
description: 'The location of the package.json to validate'
required: false
runs:
using: 'node20'
main: 'dist/main.js'
Expand Down
4 changes: 2 additions & 2 deletions dist/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -18173,7 +18173,7 @@ var validateAlphabetical = (packageJson) => {
};

// src/main.ts
var pathToPackageJson = "./package.json";
var pathToPackageJson = core8.getInput("package-json-location") || "./package.json";
var RULES_MAP = {
ranges: {
method: validateVersionRanges,
Expand Down Expand Up @@ -18212,4 +18212,4 @@ export {
RULES_MAP
};

//# debugId=653C660A130B963164756e2164756e21
//# debugId=6956EC3BADF63C5C64756e2164756e21
6 changes: 3 additions & 3 deletions dist/main.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type GithubError = {
message: string;
};

const pathToPackageJson = './package.json';
const pathToPackageJson = core.getInput('package-json-location') || './package.json';

export const RULES_MAP: {
[key: string]: {
Expand Down

0 comments on commit 9b7db69

Please sign in to comment.