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(config): Adds support for --offline flag to global add command #7330

Merged
merged 3 commits into from Jun 13, 2019
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Expand Up @@ -4,6 +4,10 @@ Please add one entry in this file for each change in Yarn's behavior. Use the sa

## Master

- Adds support for --offline flag to global add command

[#7330](https://github.com/yarnpkg/yarn/pull/7330) - [**Francis Crick**](https://guthub.com/fcrick)

- Yarn will tolerate Yaml at parse time. Full support isn't ready yet and will only come at the next major.

[#7300](https://github.com/yarnpkg/yarn/pull/7300) - [**Maël Nison**](https://twitter.com/arcanis)
Expand Down
Empty file.
5 changes: 5 additions & 0 deletions __tests__/fixtures/index/run-global-add-offline/package.json
@@ -0,0 +1,5 @@
{
"name": "test_global_add_offline",
"version": "1.0.0",
"license": "UNLICENSED"
}
15 changes: 15 additions & 0 deletions __tests__/index.js
Expand Up @@ -146,6 +146,21 @@ if (semver.satisfies(ver, '>=5.0.0')) {
});
}

test.concurrent('should fail to find non-existent package offline', async () => {
const command = execCommand(
'--offline',
['global', 'add', 'doesnotexistqwertyuiop@2.0.0-doesnotexist', '--global-folder', './global'],
'run-global-add-offline',
true,
);
await expectAnErrorMessage(
command,
`error Couldn't find any versions for "doesnotexistqwertyuiop" that matches "2.0.0-doesnotexist" in our cache ` +
'(possible versions are ""). This is usually caused by a missing entry in the lockfile, running Yarn without ' +
'the --offline flag may help fix this issue.',
);
});

test.concurrent('should run custom script', async () => {
const stdout = await execCommand('run', ['custom-script'], 'run-custom-script');
expectRunOutput(stdout);
Expand Down
1 change: 1 addition & 0 deletions src/cli/commands/global.js
Expand Up @@ -48,6 +48,7 @@ async function updateCwd(config: Config): Promise<void> {

await config.init({
cwd: config.globalFolder,
offline: config.offline,
binLinks: true,
globalFolder: config.globalFolder,
cacheFolder: config._cacheRootFolder,
Expand Down