Skip to content

Commit 9b7db69

Browse files
authored
feat: custom package.json location (#297)
1 parent 3d69646 commit 9b7db69

File tree

5 files changed

+22
-6
lines changed

5 files changed

+22
-6
lines changed

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,19 @@ Example invalid package.json this will prevent:
133133

134134
## Other Inputs
135135

136+
Specify `package-json-location` to specify another location for the package.json to validate. Defaults to `./package.json`.
137+
138+
```yaml
139+
steps:
140+
- name: Checkout
141+
uses: actions/checkout@v3
142+
143+
- uses: ExpediaGroup/package-json-validator@v1
144+
with:
145+
rules: ranges
146+
package-json-location: ./project/package.json
147+
```
148+
136149
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`.
137150

138151
```yaml

action.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ inputs:
2424
ignore-resolutions-until:
2525
description: 'Date string to skip validation for resolutions field for a specific amount of time.'
2626
required: false
27+
package-json-location:
28+
description: 'The location of the package.json to validate'
29+
required: false
2730
runs:
2831
using: 'node20'
2932
main: 'dist/main.js'

dist/main.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18173,7 +18173,7 @@ var validateAlphabetical = (packageJson) => {
1817318173
};
1817418174

1817518175
// src/main.ts
18176-
var pathToPackageJson = "./package.json";
18176+
var pathToPackageJson = core8.getInput("package-json-location") || "./package.json";
1817718177
var RULES_MAP = {
1817818178
ranges: {
1817918179
method: validateVersionRanges,
@@ -18212,4 +18212,4 @@ export {
1821218212
RULES_MAP
1821318213
};
1821418214

18215-
//# debugId=653C660A130B963164756e2164756e21
18215+
//# debugId=6956EC3BADF63C5C64756e2164756e21

dist/main.js.map

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ type GithubError = {
2525
message: string;
2626
};
2727

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

3030
export const RULES_MAP: {
3131
[key: string]: {

0 commit comments

Comments
 (0)