Skip to content

Commit

Permalink
Fix bug when cannot set a config value to empty string (#3018)
Browse files Browse the repository at this point in the history
* Fixes regression introduced in PR #2440
* Related to #2434
  • Loading branch information
iredchuk authored and arcanis committed Apr 18, 2017
1 parent 4cdc520 commit f68c101
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
10 changes: 8 additions & 2 deletions __tests__/commands/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,18 @@ test('cache-folder flag has higher priorities than .yarnrc file', (): Promise<vo
});
});

test('set true when option value is empty', (): Promise<void> => {
return runConfig(['set', 'strict-ssl', ''], {}, '', (config) => {
test('set true when option value is undefined', (): Promise<void> => {
return runConfig(['set', 'strict-ssl'], {}, '', (config) => {
expect(config.registries.yarn.homeConfig['strict-ssl']).toBe(true);
});
});

test('set empty string to an option', (): Promise<void> => {
return runConfig(['set', 'version-tag-prefix', ''], {}, '', (config) => {
expect(config.registries.yarn.homeConfig['version-tag-prefix']).toBe('');
});
});

test('set value "false" to an option', (): Promise<void> => {
return runConfig(['set', 'strict-ssl', 'false'], {}, '', (config) => {
expect(config.registries.yarn.homeConfig['strict-ssl']).toBe(false);
Expand Down
3 changes: 1 addition & 2 deletions src/cli/commands/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ export const {run, setFlags} = buildSubCommands('config', {
if (args.length === 0 || args.length > 2) {
return false;
}
const key = args[0];
const val = args[1] || true;
const [key, val = true] = args;
const yarnConfig = config.registries.yarn;
await yarnConfig.saveHomeConfig({[key]: val});
reporter.success(reporter.lang('configSet', key, val));
Expand Down

0 comments on commit f68c101

Please sign in to comment.