Skip to content

Commit ddfbfc1

Browse files
committed
fix(core): fix the value check for publishConfig.provenance
Signed-off-by: Sora Morimoto <[email protected]>
1 parent 8661aac commit ddfbfc1

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

packages/yarnpkg-core/sources/Manifest.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,9 @@ export class Manifest {
523523
if (typeof data.publishConfig.registry === `string`)
524524
this.publishConfig.registry = data.publishConfig.registry;
525525

526+
if (typeof data.publishConfig.provenance === `boolean`)
527+
this.publishConfig.provenance = data.publishConfig.provenance;
528+
526529
if (typeof data.publishConfig.bin === `string`) {
527530
if (this.name !== null) {
528531
this.publishConfig.bin = new Map([[this.name.name, normalizeSlashes(data.publishConfig.bin)]]);

packages/yarnpkg-core/tests/Manifest.test.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,21 @@ describe(`Manifest`, () => {
5555
expect(manifest.exportTo({}).bin).toEqual({bin2: `./bin2.js`});
5656
});
5757
});
58+
59+
describe(`publishConfig`, () => {
60+
it(`should parse provenance field when set to true`, () => {
61+
const manifest = Manifest.fromText(`{ "publishConfig": { "provenance": true } }`);
62+
expect(manifest.publishConfig?.provenance).toBe(true);
63+
});
64+
65+
it(`should parse provenance field when set to false`, () => {
66+
const manifest = Manifest.fromText(`{ "publishConfig": { "provenance": false } }`);
67+
expect(manifest.publishConfig?.provenance).toBe(false);
68+
});
69+
70+
it(`should ignore non-boolean provenance values`, () => {
71+
const manifest = Manifest.fromText(`{ "publishConfig": { "provenance": "true" } }`);
72+
expect(manifest.publishConfig?.provenance).toBeUndefined();
73+
});
74+
});
5875
});

0 commit comments

Comments
 (0)