From fe99160f09fac3220703a90983676efb0769e85a Mon Sep 17 00:00:00 2001 From: Trevor Brindle Date: Thu, 15 Mar 2018 17:58:40 -0400 Subject: [PATCH] fix: retain semver symbols on snapshot update (#191) --- __tests__/command_helpers/checkCLIForUpdates.ts | 16 ++++++++++++++++ src/extensions/functions/checkCLIForUpdates.ts | 6 +++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/__tests__/command_helpers/checkCLIForUpdates.ts b/__tests__/command_helpers/checkCLIForUpdates.ts index fded26a..9cc4f60 100644 --- a/__tests__/command_helpers/checkCLIForUpdates.ts +++ b/__tests__/command_helpers/checkCLIForUpdates.ts @@ -8,6 +8,13 @@ const rule = { version: '--version', } +const ruleTildeSemver = { + rule: 'cli', + binary: 'npm', + semver: '~5.6.0', + version: '--version', +} + const ruleNoSemver = { rule: 'cli', binary: 'yarn', @@ -50,5 +57,14 @@ describe('checkCLIForUpdates', () => { expect(result).toEqual(undefined) expect(ruleNoSemver.semver).toBe(undefined) }) + + it('copies semver ~ symbol if present', async () => { + context.solidarity = { + getVersion: jest.fn(() => '5.8'), + } + + const result = await checkCLIForUpdates(ruleTildeSemver, context) + expect(result).toEqual("Setting npm to '~5.8'") + }) }) }) diff --git a/src/extensions/functions/checkCLIForUpdates.ts b/src/extensions/functions/checkCLIForUpdates.ts index c1c4599..7c48652 100644 --- a/src/extensions/functions/checkCLIForUpdates.ts +++ b/src/extensions/functions/checkCLIForUpdates.ts @@ -20,10 +20,10 @@ module.exports = async (rule: CLIRule, context: SolidarityRunContext): Promise