diff --git a/CHANGELOG.md b/CHANGELOG.md index 047f33c4a0..2692163a6a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/__tests__/fixtures/index/run-global-add-offline/global/.gitkeep b/__tests__/fixtures/index/run-global-add-offline/global/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/__tests__/fixtures/index/run-global-add-offline/package.json b/__tests__/fixtures/index/run-global-add-offline/package.json new file mode 100644 index 0000000000..a183089a65 --- /dev/null +++ b/__tests__/fixtures/index/run-global-add-offline/package.json @@ -0,0 +1,5 @@ +{ + "name": "test_global_add_offline", + "version": "1.0.0", + "license": "UNLICENSED" +} diff --git a/__tests__/index.js b/__tests__/index.js index 6c1c73961f..80345e9569 100644 --- a/__tests__/index.js +++ b/__tests__/index.js @@ -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); diff --git a/src/cli/commands/global.js b/src/cli/commands/global.js index 1ab16f21b4..a502cc6659 100644 --- a/src/cli/commands/global.js +++ b/src/cli/commands/global.js @@ -48,6 +48,7 @@ async function updateCwd(config: Config): Promise { await config.init({ cwd: config.globalFolder, + offline: config.offline, binLinks: true, globalFolder: config.globalFolder, cacheFolder: config._cacheRootFolder,