diff --git a/package.json b/package.json index 1ccd115..6aff77a 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "test": "jest" }, "devDependencies": { - "@fensak-io/reng": "^1.0.7", + "@fensak-io/reng": "^1.1.2", "@octokit/rest": "^20.0.2", "@jest/globals": "^29.7.0", "eslint": "^8.50.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 1ad1e27..c745dad 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -6,8 +6,8 @@ settings: devDependencies: "@fensak-io/reng": - specifier: ^1.0.7 - version: 1.0.7 + specifier: ^1.1.2 + version: 1.1.2 "@jest/globals": specifier: ^29.7.0 version: 29.7.0 @@ -1649,10 +1649,10 @@ packages: engines: { node: ^12.22.0 || ^14.17.0 || >=16.0.0 } dev: true - /@fensak-io/reng@1.0.7: + /@fensak-io/reng@1.1.2: resolution: { - integrity: sha512-7wPbjzJUZ6qC9QdKNcUawFLd9ckGV5JxoXMAMob2gzkcaWXGFUq4/AecfLSnHEKYXf7zOrzzWQ2tqn6ETWs5aw==, + integrity: sha512-rGWP3CavRc7VJLD8PrOlwnS8O8knm4G/QGD12eq1RoGTuhE4+oXMDYgcCT5Tpp9CiUjdNn+vtgbfKwaHIRf+Og==, } dependencies: "@babel/core": 7.23.2 diff --git a/rules/sample.js b/rules/sample.js index 57e9c6d..267c40f 100644 --- a/rules/sample.js +++ b/rules/sample.js @@ -3,7 +3,7 @@ * the root README.md file. */ -function main(inp) { +function main(inp, _metadata) { const numPatches = inp.length; if (numPatches == 0) { // No files updated, so approve. diff --git a/rules/sample.test.js b/rules/sample.test.js index c6602c9..4e061a1 100644 --- a/rules/sample.test.js +++ b/rules/sample.test.js @@ -25,7 +25,7 @@ const testRepo = { const opts = { logMode: RuleLogMode.Console }; test("No changes should be approved", async () => { - const result = await runRule(ruleFn, [], opts); + const result = await runRule(ruleFn, [], { sourceBranch: "foo" }, opts); expect(result.approve).toBe(true); }); @@ -33,7 +33,12 @@ test("Changes only to README should be approved", async () => { // View PR at // https://github.com/fensak-io/dotfensak-deno-template/pull/1 const patches = await patchFromGitHubPullRequest(octokit, testRepo, 1); - const result = await runRule(ruleFn, patches.patchList, opts); + const result = await runRule( + ruleFn, + patches.patchList, + patches.metadata, + opts, + ); expect(result.approve).toBe(true); }); @@ -41,7 +46,12 @@ test("Changes to non-README files should be rejected", async () => { // View PR at // https://github.com/fensak-io/dotfensak-deno-template/pull/2 const patches = await patchFromGitHubPullRequest(octokit, testRepo, 2); - const result = await runRule(ruleFn, patches.patchList, opts); + const result = await runRule( + ruleFn, + patches.patchList, + patches.metadata, + opts, + ); expect(result.approve).toBe(false); }); @@ -49,6 +59,11 @@ test("Change containing more than one file should be rejected", async () => { // View PR at // https://github.com/fensak-io/dotfensak-deno-template/pull/4 const patches = await patchFromGitHubPullRequest(octokit, testRepo, 4); - const result = await runRule(ruleFn, patches.patchList, opts); + const result = await runRule( + ruleFn, + patches.patchList, + patches.metadata, + opts, + ); expect(result.approve).toBe(false); });