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

Set boolean config values correctly #2440

Merged
merged 1 commit into from
Jan 14, 2017
Merged
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
18 changes: 18 additions & 0 deletions __tests__/commands/cache.js → __tests__/commands/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,21 @@ test('cache-folder flag has higher priorities than .yarnrc file', (): Promise<vo
expect(config.cacheFolder).toContain('flag_config_folder_dir');
});
});

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

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);
});
});

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

const [key, val = true] = args;
const key = args[0];
const val = args[1] || true;
const yarnConfig = config.registries.yarn;
await yarnConfig.saveHomeConfig({[key]: val});
reporter.success(reporter.lang('configSet', key, val));
Expand Down
2 changes: 2 additions & 0 deletions src/registries/yarn-registry.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ export default class YarnRegistry extends NpmRegistry {
}

async saveHomeConfig(config: Object): Promise<void> {
YarnRegistry.normalizeConfig(config);

for (const key in config) {
const val = config[key];

Expand Down