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

Rc args extra tests #3053

Merged
merged 2 commits into from
Apr 6, 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
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--install.cache-folder /tmp/foobar
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--cache.cache-folder /tmp/foobar
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{
}
12 changes: 11 additions & 1 deletion __tests__/lifecycle-scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,21 @@ async function execCommand(cmd: string, packageName: string, env = process.env):
});
}

test('should add the yarnrc values to the command line', async () => {
test('should add the global yarnrc arguments to the command line', async () => {
const stdout = await execCommand('cache dir', 'yarnrc-cli');
expect(stdout.replace(/\\/g, '/')).toMatch(/^\/tmp\/foobar\/v[0-9]+\n$/);
});

test('should add the command-specific yarnrc arguments to the command line if the command name matches', async () => {
const stdout = await execCommand('cache dir', 'yarnrc-cli-command-specific-ok');
expect(stdout.replace(/\\/g, '/')).toMatch(/^\/tmp\/foobar\/v[0-9]+\n$/);
});

test('should not add the command-specific yarnrc arguments if the command name doesn\'t match', async () => {
const stdout = await execCommand('cache dir', 'yarnrc-cli-command-specific-ko');
expect(stdout.replace(/\\/g, '/')).not.toMatch(/^\/tmp\/foobar\/v[0-9]+\n$/);
});

test('should allow overriding the yarnrc values from the command line', async () => {
const stdout = await execCommand('cache dir --cache-folder /tmp/toto', 'yarnrc-cli');
expect(stdout.replace(/\\/g, '/')).toMatch(/^\/tmp\/toto\/v[0-9]+\n$/);
Expand Down
4 changes: 3 additions & 1 deletion src/rc.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,10 @@ const buildRcArgs = () => Object.keys(getRcConf()).reduce((argLists, key) => {

if (typeof value === 'string') {
argLists[namespace] = argLists[namespace].concat([`--${arg}`, value]);
} else {
} else if (value === true) {
argLists[namespace] = argLists[namespace].concat([`--${arg}`]);
} else if (value === false) {
argLists[namespace] = argLists[namespace].concat([`--no-${arg}`]);
}

return argLists;
Expand Down