Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix default source overriding config file #123

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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