From 9ca6fa06b4ac1d4ba185ba070281d7db89374130 Mon Sep 17 00:00:00 2001 From: Ethan Arrowood Date: Mon, 2 May 2022 16:05:31 -0600 Subject: [PATCH] aint pretty but it works --- __tests__/installer.test.ts | 15 ++++++++++++--- dist/setup/index.js | 3 +-- src/main.ts | 2 +- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/__tests__/installer.test.ts b/__tests__/installer.test.ts index 44de65b2..98cc10b3 100644 --- a/__tests__/installer.test.ts +++ b/__tests__/installer.test.ts @@ -911,11 +911,20 @@ describe('setup-node', () => { }); describe('corepack', () => { - it.only('supports pnpm automatically from Node v14+', async () => { - inputs['node-version'] = '14.9.0'; + it('supports pnpm automatically from Node v14+', async () => { + inputs['node-version'] = '14.19.0'; inputs['cache'] = 'pnpm'; + + inSpy.mockImplementation(name => inputs[name]); + + isCacheActionAvailable.mockImplementation(() => true); + + const toolPath = path.normalize('/cache/node/14.19.0/x64'); + findSpy.mockReturnValue(toolPath); + await main.run(); - expect(execSpy).toBeCalledWith('corepack enable'); + + expect(cnSpy).toHaveBeenNthCalledWith(2, `[command]${process.execPath.substring(0, process.execPath.length - 4)}corepack enable\n`); }) }) }); diff --git a/dist/setup/index.js b/dist/setup/index.js index 751c584e..d502ee62 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -6517,10 +6517,9 @@ function run() { if (registryUrl) { auth.configAuthentication(registryUrl, alwaysAuth); } - core.info('here'); if (cache && cache_utils_1.isCacheFeatureAvailable()) { + core.info('here'); if (semver_1.default.gte(version, '14.19.0')) { - core.info('here'); try { core.info(yield cache_utils_1.getCommandOutput('corepack enable')); } diff --git a/src/main.ts b/src/main.ts index 3cc939cb..59a23a74 100644 --- a/src/main.ts +++ b/src/main.ts @@ -6,7 +6,7 @@ import * as path from 'path'; import {restoreCache} from './cache-restore'; import {isGhes, isCacheFeatureAvailable, getCommandOutput} from './cache-utils'; import os = require('os'); -import semver from 'semver'; +import * as semver from 'semver'; export async function run() { try {