Skip to content

Commit

Permalink
fix(config): Adds support for --offline flag to global add command (#…
Browse files Browse the repository at this point in the history
…7330)

* fix(config): Adds support for --offline flag to global add command

* Update CHANGELOG.md

* lower line lengths below 120
  • Loading branch information
fcrick authored and arcanis committed Jun 13, 2019
1 parent b656953 commit 6b7ee8c
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 0 deletions.
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

0 comments on commit 6b7ee8c

Please sign in to comment.