Skip to content

Commit

Permalink
Fix default source overriding config file
Browse files Browse the repository at this point in the history
  • Loading branch information
bpolge-kr committed Feb 22, 2023
1 parent 2f1ffba commit 65cc7c6
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/get-context/get-config/get-config.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ describe('semverRange', () => {
});

describe('source', () => {
it('uses default when not set', () => {
it('defaults to [] when not set', () => {
const disk = mockDisk();
const config = getConfig(disk, {});
expect(R.getExn(config).source).toEqual([]);
Expand Down
6 changes: 4 additions & 2 deletions src/get-context/get-config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function unSafeGetConfig(
semverRange: getConfigByName('semverRange'),
sortAz: getConfigByName('sortAz'),
sortFirst: getConfigByName('sortFirst'),
source: getConfigByName('source'),
source: getConfigByName('source', []),
types: fromCli?.types,
versionGroups: getConfigByName('versionGroups'),
});
Expand Down Expand Up @@ -78,10 +78,12 @@ function unSafeGetConfig(

return allConfig;

function getConfigByName(name: keyof Syncpack.Config.Public): unknown {
function getConfigByName(name: keyof Syncpack.Config.Public, defaultValue?: any): unknown {
if (typeof (fromCli as any)[name] !== 'undefined')
return (fromCli as Syncpack.Config.Public)[name];
if (typeof (fromRcFile as any)[name] !== 'undefined')
return (fromRcFile as Syncpack.Config.Public)[name];
if (defaultValue)
return defaultValue
}
}
1 change: 0 additions & 1 deletion src/option.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ export const option = {
'-s, --source [pattern]',
'glob pattern for package.json files to read from',
collect,
[] as string[],
],
types: [
'-t, --types <names>',
Expand Down

0 comments on commit 65cc7c6

Please sign in to comment.