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

Add tests for global command #3238

Merged
merged 7 commits into from
May 2, 2017
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
add test for global add command
voxsim committed May 2, 2017

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
commit f10efb779a47b5127d9b3951e9df2fc0cce0223f
2 changes: 1 addition & 1 deletion __tests__/commands/_helpers.js
Original file line number Diff line number Diff line change
@@ -122,7 +122,7 @@ export async function run<T, R>(
const config = await Config.create({
binLinks: !!flags.binLinks,
cwd,
globalFolder: path.join(cwd, '.yarn-global'),
globalFolder: flags.globalFolder || path.join(cwd, '.yarn-global'),
cacheFolder: flags.cacheFolder || path.join(cwd, '.yarn-cache'),
linkFolder: flags.linkFolder || path.join(cwd, '.yarn-link'),
production: flags.production,
10 changes: 9 additions & 1 deletion __tests__/commands/global.js
Original file line number Diff line number Diff line change
@@ -68,10 +68,18 @@ test('add with PREFIX enviroment variable', (): Promise<void> => {
});
});

test.concurrent('bin', () => {
test.concurrent('bin', (): Promise<void> => {
const tmpGlobalFolder = getTempGlobalFolder();
return runGlobal(['bin'], {prefix: tmpGlobalFolder}, 'add-with-prefix-flag',
(config, reporter, install, getStdout) => {
expect(getStdout()).toContain(path.join(tmpGlobalFolder, 'bin'));
});
});

test.concurrent('add', async (): Promise<void> => {
const tmpGlobalFolder = await createTempGlobalFolder();
return runGlobal(['add', 'react-native-cli'], {globalFolder: tmpGlobalFolder}, 'add-with-prefix-flag',
async (config) => {
expect(await fs.exists(path.join(tmpGlobalFolder, 'node_modules', 'react-native-cli'))).toEqual(true);
});
});
4 changes: 1 addition & 3 deletions src/cli/index.js
Original file line number Diff line number Diff line change
@@ -51,7 +51,7 @@ commander.option('--no-lockfile', "don't read or generate a lockfile");
commander.option('--pure-lockfile', "don't generate a lockfile");
commander.option('--frozen-lockfile', "don't generate a lockfile and fail if an update is needed");
commander.option('--link-duplicates', 'create hardlinks to the repeated modules in node_modules');
commander.option('--global-folder <path>', '');
commander.option('--global-folder <path>', 'specify a custom folder to store global packages');
commander.option(
'--modules-folder <path>',
'rather than installing modules into the node_modules folder relative to the cwd, output them here',
@@ -299,7 +299,6 @@ function writeErrorReport(log) : ?string {
return errorReportLoc;
}

//
config.init({
binLinks: commander.binLinks,
modulesFolder: commander.modulesFolder,
@@ -319,7 +318,6 @@ config.init({
nonInteractive: commander.nonInteractive,
commandName: commandName === 'run' ? commander.args[0] : commandName,
}).then(() => {

// option "no-progress" stored in yarn config
const noProgressConfig = config.registries.yarn.getOption('no-progress');