mirror of
https://gitea.com/actions/setup-node.git
synced 2024-11-24 02:59:33 +01:00
fix: change from using env to os module
This commit is contained in:
parent
2c3ea16a59
commit
8454a14c98
3 changed files with 14 additions and 10 deletions
|
@ -2,20 +2,15 @@ import * as core from '@actions/core';
|
|||
import * as cache from '@actions/cache';
|
||||
import * as path from 'path';
|
||||
import * as glob from '@actions/glob';
|
||||
import osm from 'os';
|
||||
|
||||
import * as utils from '../src/cache-utils';
|
||||
import {restoreCache} from '../src/cache-restore';
|
||||
|
||||
describe('cache-restore', () => {
|
||||
process.env['GITHUB_WORKSPACE'] = path.join(__dirname, 'data');
|
||||
if (!process.env.RUNNER_OS) {
|
||||
process.env.RUNNER_OS = 'Linux';
|
||||
}
|
||||
if (!process.env.RUNNER_ARCH) {
|
||||
process.env.RUNNER_ARCH = 'X64';
|
||||
}
|
||||
const platform = process.env.RUNNER_OS;
|
||||
const arch = process.env.RUNNER_ARCH;
|
||||
const platform = 'Linux';
|
||||
const arch = 'arm64';
|
||||
const commonPath = '/some/random/path';
|
||||
const npmCachePath = `${commonPath}/npm`;
|
||||
const pnpmCachePath = `${commonPath}/pnpm`;
|
||||
|
@ -56,6 +51,8 @@ describe('cache-restore', () => {
|
|||
let getCommandOutputSpy: jest.SpyInstance;
|
||||
let restoreCacheSpy: jest.SpyInstance;
|
||||
let hashFilesSpy: jest.SpyInstance;
|
||||
let archSpy: jest.SpyInstance;
|
||||
let platformSpy: jest.SpyInstance;
|
||||
|
||||
beforeEach(() => {
|
||||
// core
|
||||
|
@ -106,6 +103,13 @@ describe('cache-restore', () => {
|
|||
|
||||
// cache-utils
|
||||
getCommandOutputSpy = jest.spyOn(utils, 'getCommandOutput');
|
||||
|
||||
// os
|
||||
archSpy = jest.spyOn(osm, 'arch');
|
||||
archSpy.mockImplementation(() => arch);
|
||||
|
||||
platformSpy = jest.spyOn(osm, 'platform');
|
||||
platformSpy.mockImplementation(() => platform);
|
||||
});
|
||||
|
||||
describe('Validate provided package manager', () => {
|
||||
|
|
2
dist/setup/index.js
vendored
2
dist/setup/index.js
vendored
|
@ -92567,7 +92567,7 @@ const restoreCache = (packageManager, cacheDependencyPath) => __awaiter(void 0,
|
|||
if (!packageManagerInfo) {
|
||||
throw new Error(`Caching for '${packageManager}' is not supported`);
|
||||
}
|
||||
const platform = process.env.RUNNER_OS;
|
||||
const platform = os_1.default.platform();
|
||||
const arch = os_1.default.arch();
|
||||
const cachePaths = yield (0, cache_utils_1.getCacheDirectories)(packageManagerInfo, cacheDependencyPath);
|
||||
core.saveState(constants_1.State.CachePaths, cachePaths);
|
||||
|
|
|
@ -21,7 +21,7 @@ export const restoreCache = async (
|
|||
if (!packageManagerInfo) {
|
||||
throw new Error(`Caching for '${packageManager}' is not supported`);
|
||||
}
|
||||
const platform = process.env.RUNNER_OS;
|
||||
const platform = os.platform();
|
||||
const arch = os.arch();
|
||||
|
||||
const cachePaths = await getCacheDirectories(
|
||||
|
|
Loading…
Reference in a new issue