You've already forked setup-node
mirror of
https://github.com/actions/setup-node.git
synced 2025-07-15 03:20:29 +07:00
Compare commits
3 Commits
update-tem
...
v3.8.1
Author | SHA1 | Date | |
---|---|---|---|
5e21ff4d9b | |||
bea5baf987 | |||
d82f92a0eb |
@ -92,6 +92,9 @@ describe('run', () => {
|
|||||||
|
|
||||||
it('Package manager is not valid, skip caching', async () => {
|
it('Package manager is not valid, skip caching', async () => {
|
||||||
inputs['cache'] = 'yarn3';
|
inputs['cache'] = 'yarn3';
|
||||||
|
getStateSpy.mockImplementation(key =>
|
||||||
|
key === State.CachePackageManager ? inputs['cache'] : ''
|
||||||
|
);
|
||||||
|
|
||||||
await run();
|
await run();
|
||||||
|
|
||||||
@ -108,7 +111,9 @@ describe('run', () => {
|
|||||||
it('should not save cache for yarn1', async () => {
|
it('should not save cache for yarn1', async () => {
|
||||||
inputs['cache'] = 'yarn';
|
inputs['cache'] = 'yarn';
|
||||||
getStateSpy.mockImplementation(key =>
|
getStateSpy.mockImplementation(key =>
|
||||||
key === State.CachePrimaryKey || key === State.CacheMatchedKey
|
key === State.CachePackageManager
|
||||||
|
? inputs['cache']
|
||||||
|
: key === State.CachePrimaryKey || key === State.CacheMatchedKey
|
||||||
? yarnFileHash
|
? yarnFileHash
|
||||||
: key === State.CachePaths
|
: key === State.CachePaths
|
||||||
? '["/foo/bar"]'
|
? '["/foo/bar"]'
|
||||||
@ -117,8 +122,8 @@ describe('run', () => {
|
|||||||
|
|
||||||
await run();
|
await run();
|
||||||
|
|
||||||
expect(getInputSpy).toHaveBeenCalled();
|
expect(getInputSpy).not.toHaveBeenCalled();
|
||||||
expect(getStateSpy).toHaveBeenCalledTimes(3);
|
expect(getStateSpy).toHaveBeenCalledTimes(4);
|
||||||
expect(getCommandOutputSpy).toHaveBeenCalledTimes(0);
|
expect(getCommandOutputSpy).toHaveBeenCalledTimes(0);
|
||||||
expect(debugSpy).toHaveBeenCalledTimes(0);
|
expect(debugSpy).toHaveBeenCalledTimes(0);
|
||||||
expect(infoSpy).toHaveBeenCalledWith(
|
expect(infoSpy).toHaveBeenCalledWith(
|
||||||
@ -130,7 +135,9 @@ describe('run', () => {
|
|||||||
it('should not save cache for yarn2', async () => {
|
it('should not save cache for yarn2', async () => {
|
||||||
inputs['cache'] = 'yarn';
|
inputs['cache'] = 'yarn';
|
||||||
getStateSpy.mockImplementation(key =>
|
getStateSpy.mockImplementation(key =>
|
||||||
key === State.CachePrimaryKey || key === State.CacheMatchedKey
|
key === State.CachePackageManager
|
||||||
|
? inputs['cache']
|
||||||
|
: key === State.CachePrimaryKey || key === State.CacheMatchedKey
|
||||||
? yarnFileHash
|
? yarnFileHash
|
||||||
: key === State.CachePaths
|
: key === State.CachePaths
|
||||||
? '["/foo/bar"]'
|
? '["/foo/bar"]'
|
||||||
@ -139,8 +146,8 @@ describe('run', () => {
|
|||||||
|
|
||||||
await run();
|
await run();
|
||||||
|
|
||||||
expect(getInputSpy).toHaveBeenCalled();
|
expect(getInputSpy).not.toHaveBeenCalled();
|
||||||
expect(getStateSpy).toHaveBeenCalledTimes(3);
|
expect(getStateSpy).toHaveBeenCalledTimes(4);
|
||||||
expect(getCommandOutputSpy).toHaveBeenCalledTimes(0);
|
expect(getCommandOutputSpy).toHaveBeenCalledTimes(0);
|
||||||
expect(debugSpy).toHaveBeenCalledTimes(0);
|
expect(debugSpy).toHaveBeenCalledTimes(0);
|
||||||
expect(infoSpy).toHaveBeenCalledWith(
|
expect(infoSpy).toHaveBeenCalledWith(
|
||||||
@ -152,7 +159,9 @@ describe('run', () => {
|
|||||||
it('should not save cache for npm', async () => {
|
it('should not save cache for npm', async () => {
|
||||||
inputs['cache'] = 'npm';
|
inputs['cache'] = 'npm';
|
||||||
getStateSpy.mockImplementation(key =>
|
getStateSpy.mockImplementation(key =>
|
||||||
key === State.CachePrimaryKey || key === State.CacheMatchedKey
|
key === State.CachePackageManager
|
||||||
|
? inputs['cache']
|
||||||
|
: key === State.CachePrimaryKey || key === State.CacheMatchedKey
|
||||||
? yarnFileHash
|
? yarnFileHash
|
||||||
: key === State.CachePaths
|
: key === State.CachePaths
|
||||||
? '["/foo/bar"]'
|
? '["/foo/bar"]'
|
||||||
@ -162,8 +171,8 @@ describe('run', () => {
|
|||||||
|
|
||||||
await run();
|
await run();
|
||||||
|
|
||||||
expect(getInputSpy).toHaveBeenCalled();
|
expect(getInputSpy).not.toHaveBeenCalled();
|
||||||
expect(getStateSpy).toHaveBeenCalledTimes(3);
|
expect(getStateSpy).toHaveBeenCalledTimes(4);
|
||||||
expect(getCommandOutputSpy).toHaveBeenCalledTimes(0);
|
expect(getCommandOutputSpy).toHaveBeenCalledTimes(0);
|
||||||
expect(debugSpy).toHaveBeenCalledTimes(0);
|
expect(debugSpy).toHaveBeenCalledTimes(0);
|
||||||
expect(setFailedSpy).not.toHaveBeenCalled();
|
expect(setFailedSpy).not.toHaveBeenCalled();
|
||||||
@ -172,7 +181,9 @@ describe('run', () => {
|
|||||||
it('should not save cache for pnpm', async () => {
|
it('should not save cache for pnpm', async () => {
|
||||||
inputs['cache'] = 'pnpm';
|
inputs['cache'] = 'pnpm';
|
||||||
getStateSpy.mockImplementation(key =>
|
getStateSpy.mockImplementation(key =>
|
||||||
key === State.CachePrimaryKey || key === State.CacheMatchedKey
|
key === State.CachePackageManager
|
||||||
|
? inputs['cache']
|
||||||
|
: key === State.CachePrimaryKey || key === State.CacheMatchedKey
|
||||||
? yarnFileHash
|
? yarnFileHash
|
||||||
: key === State.CachePaths
|
: key === State.CachePaths
|
||||||
? '["/foo/bar"]'
|
? '["/foo/bar"]'
|
||||||
@ -181,8 +192,8 @@ describe('run', () => {
|
|||||||
|
|
||||||
await run();
|
await run();
|
||||||
|
|
||||||
expect(getInputSpy).toHaveBeenCalled();
|
expect(getInputSpy).not.toHaveBeenCalled();
|
||||||
expect(getStateSpy).toHaveBeenCalledTimes(3);
|
expect(getStateSpy).toHaveBeenCalledTimes(4);
|
||||||
expect(getCommandOutputSpy).toHaveBeenCalledTimes(0);
|
expect(getCommandOutputSpy).toHaveBeenCalledTimes(0);
|
||||||
expect(debugSpy).toHaveBeenCalledTimes(0);
|
expect(debugSpy).toHaveBeenCalledTimes(0);
|
||||||
expect(setFailedSpy).not.toHaveBeenCalled();
|
expect(setFailedSpy).not.toHaveBeenCalled();
|
||||||
@ -193,7 +204,9 @@ describe('run', () => {
|
|||||||
it('saves cache from yarn 1', async () => {
|
it('saves cache from yarn 1', async () => {
|
||||||
inputs['cache'] = 'yarn';
|
inputs['cache'] = 'yarn';
|
||||||
getStateSpy.mockImplementation((key: string) =>
|
getStateSpy.mockImplementation((key: string) =>
|
||||||
key === State.CacheMatchedKey
|
key === State.CachePackageManager
|
||||||
|
? inputs['cache']
|
||||||
|
: key === State.CacheMatchedKey
|
||||||
? yarnFileHash
|
? yarnFileHash
|
||||||
: key === State.CachePrimaryKey
|
: key === State.CachePrimaryKey
|
||||||
? npmFileHash
|
? npmFileHash
|
||||||
@ -204,8 +217,8 @@ describe('run', () => {
|
|||||||
|
|
||||||
await run();
|
await run();
|
||||||
|
|
||||||
expect(getInputSpy).toHaveBeenCalled();
|
expect(getInputSpy).not.toHaveBeenCalled();
|
||||||
expect(getStateSpy).toHaveBeenCalledTimes(3);
|
expect(getStateSpy).toHaveBeenCalledTimes(4);
|
||||||
expect(getCommandOutputSpy).toHaveBeenCalledTimes(0);
|
expect(getCommandOutputSpy).toHaveBeenCalledTimes(0);
|
||||||
expect(debugSpy).toHaveBeenCalledTimes(0);
|
expect(debugSpy).toHaveBeenCalledTimes(0);
|
||||||
expect(infoSpy).not.toHaveBeenCalledWith(
|
expect(infoSpy).not.toHaveBeenCalledWith(
|
||||||
@ -221,7 +234,9 @@ describe('run', () => {
|
|||||||
it('saves cache from yarn 2', async () => {
|
it('saves cache from yarn 2', async () => {
|
||||||
inputs['cache'] = 'yarn';
|
inputs['cache'] = 'yarn';
|
||||||
getStateSpy.mockImplementation((key: string) =>
|
getStateSpy.mockImplementation((key: string) =>
|
||||||
key === State.CacheMatchedKey
|
key === State.CachePackageManager
|
||||||
|
? inputs['cache']
|
||||||
|
: key === State.CacheMatchedKey
|
||||||
? yarnFileHash
|
? yarnFileHash
|
||||||
: key === State.CachePrimaryKey
|
: key === State.CachePrimaryKey
|
||||||
? npmFileHash
|
? npmFileHash
|
||||||
@ -232,8 +247,8 @@ describe('run', () => {
|
|||||||
|
|
||||||
await run();
|
await run();
|
||||||
|
|
||||||
expect(getInputSpy).toHaveBeenCalled();
|
expect(getInputSpy).not.toHaveBeenCalled();
|
||||||
expect(getStateSpy).toHaveBeenCalledTimes(3);
|
expect(getStateSpy).toHaveBeenCalledTimes(4);
|
||||||
expect(getCommandOutputSpy).toHaveBeenCalledTimes(0);
|
expect(getCommandOutputSpy).toHaveBeenCalledTimes(0);
|
||||||
expect(debugSpy).toHaveBeenCalledTimes(0);
|
expect(debugSpy).toHaveBeenCalledTimes(0);
|
||||||
expect(infoSpy).not.toHaveBeenCalledWith(
|
expect(infoSpy).not.toHaveBeenCalledWith(
|
||||||
@ -249,7 +264,9 @@ describe('run', () => {
|
|||||||
it('saves cache from npm', async () => {
|
it('saves cache from npm', async () => {
|
||||||
inputs['cache'] = 'npm';
|
inputs['cache'] = 'npm';
|
||||||
getStateSpy.mockImplementation((key: string) =>
|
getStateSpy.mockImplementation((key: string) =>
|
||||||
key === State.CacheMatchedKey
|
key === State.CachePackageManager
|
||||||
|
? inputs['cache']
|
||||||
|
: key === State.CacheMatchedKey
|
||||||
? npmFileHash
|
? npmFileHash
|
||||||
: key === State.CachePrimaryKey
|
: key === State.CachePrimaryKey
|
||||||
? yarnFileHash
|
? yarnFileHash
|
||||||
@ -260,8 +277,8 @@ describe('run', () => {
|
|||||||
|
|
||||||
await run();
|
await run();
|
||||||
|
|
||||||
expect(getInputSpy).toHaveBeenCalled();
|
expect(getInputSpy).not.toHaveBeenCalled();
|
||||||
expect(getStateSpy).toHaveBeenCalledTimes(3);
|
expect(getStateSpy).toHaveBeenCalledTimes(4);
|
||||||
expect(getCommandOutputSpy).toHaveBeenCalledTimes(0);
|
expect(getCommandOutputSpy).toHaveBeenCalledTimes(0);
|
||||||
expect(debugSpy).toHaveBeenCalledTimes(0);
|
expect(debugSpy).toHaveBeenCalledTimes(0);
|
||||||
expect(infoSpy).not.toHaveBeenCalledWith(
|
expect(infoSpy).not.toHaveBeenCalledWith(
|
||||||
@ -277,7 +294,9 @@ describe('run', () => {
|
|||||||
it('saves cache from pnpm', async () => {
|
it('saves cache from pnpm', async () => {
|
||||||
inputs['cache'] = 'pnpm';
|
inputs['cache'] = 'pnpm';
|
||||||
getStateSpy.mockImplementation((key: string) =>
|
getStateSpy.mockImplementation((key: string) =>
|
||||||
key === State.CacheMatchedKey
|
key === State.CachePackageManager
|
||||||
|
? inputs['cache']
|
||||||
|
: key === State.CacheMatchedKey
|
||||||
? pnpmFileHash
|
? pnpmFileHash
|
||||||
: key === State.CachePrimaryKey
|
: key === State.CachePrimaryKey
|
||||||
? npmFileHash
|
? npmFileHash
|
||||||
@ -288,8 +307,8 @@ describe('run', () => {
|
|||||||
|
|
||||||
await run();
|
await run();
|
||||||
|
|
||||||
expect(getInputSpy).toHaveBeenCalled();
|
expect(getInputSpy).not.toHaveBeenCalled();
|
||||||
expect(getStateSpy).toHaveBeenCalledTimes(3);
|
expect(getStateSpy).toHaveBeenCalledTimes(4);
|
||||||
expect(getCommandOutputSpy).toHaveBeenCalledTimes(0);
|
expect(getCommandOutputSpy).toHaveBeenCalledTimes(0);
|
||||||
expect(debugSpy).toHaveBeenCalledTimes(0);
|
expect(debugSpy).toHaveBeenCalledTimes(0);
|
||||||
expect(infoSpy).not.toHaveBeenCalledWith(
|
expect(infoSpy).not.toHaveBeenCalledWith(
|
||||||
@ -305,7 +324,9 @@ describe('run', () => {
|
|||||||
it('save with -1 cacheId , should not fail workflow', async () => {
|
it('save with -1 cacheId , should not fail workflow', async () => {
|
||||||
inputs['cache'] = 'npm';
|
inputs['cache'] = 'npm';
|
||||||
getStateSpy.mockImplementation((key: string) =>
|
getStateSpy.mockImplementation((key: string) =>
|
||||||
key === State.CacheMatchedKey
|
key === State.CachePackageManager
|
||||||
|
? inputs['cache']
|
||||||
|
: key === State.CacheMatchedKey
|
||||||
? npmFileHash
|
? npmFileHash
|
||||||
: key === State.CachePrimaryKey
|
: key === State.CachePrimaryKey
|
||||||
? yarnFileHash
|
? yarnFileHash
|
||||||
@ -319,8 +340,8 @@ describe('run', () => {
|
|||||||
|
|
||||||
await run();
|
await run();
|
||||||
|
|
||||||
expect(getInputSpy).toHaveBeenCalled();
|
expect(getInputSpy).not.toHaveBeenCalled();
|
||||||
expect(getStateSpy).toHaveBeenCalledTimes(3);
|
expect(getStateSpy).toHaveBeenCalledTimes(4);
|
||||||
expect(getCommandOutputSpy).toHaveBeenCalledTimes(0);
|
expect(getCommandOutputSpy).toHaveBeenCalledTimes(0);
|
||||||
expect(debugSpy).toHaveBeenCalledTimes(0);
|
expect(debugSpy).toHaveBeenCalledTimes(0);
|
||||||
expect(infoSpy).not.toHaveBeenCalledWith(
|
expect(infoSpy).not.toHaveBeenCalledWith(
|
||||||
@ -336,7 +357,9 @@ describe('run', () => {
|
|||||||
it('saves with error from toolkit, should fail workflow', async () => {
|
it('saves with error from toolkit, should fail workflow', async () => {
|
||||||
inputs['cache'] = 'npm';
|
inputs['cache'] = 'npm';
|
||||||
getStateSpy.mockImplementation((key: string) =>
|
getStateSpy.mockImplementation((key: string) =>
|
||||||
key === State.CacheMatchedKey
|
key === State.CachePackageManager
|
||||||
|
? inputs['cache']
|
||||||
|
: key === State.CacheMatchedKey
|
||||||
? npmFileHash
|
? npmFileHash
|
||||||
: key === State.CachePrimaryKey
|
: key === State.CachePrimaryKey
|
||||||
? yarnFileHash
|
? yarnFileHash
|
||||||
@ -350,8 +373,8 @@ describe('run', () => {
|
|||||||
|
|
||||||
await run();
|
await run();
|
||||||
|
|
||||||
expect(getInputSpy).toHaveBeenCalled();
|
expect(getInputSpy).not.toHaveBeenCalled();
|
||||||
expect(getStateSpy).toHaveBeenCalledTimes(3);
|
expect(getStateSpy).toHaveBeenCalledTimes(4);
|
||||||
expect(getCommandOutputSpy).toHaveBeenCalledTimes(0);
|
expect(getCommandOutputSpy).toHaveBeenCalledTimes(0);
|
||||||
expect(debugSpy).toHaveBeenCalledTimes(0);
|
expect(debugSpy).toHaveBeenCalledTimes(0);
|
||||||
expect(infoSpy).not.toHaveBeenCalledWith(
|
expect(infoSpy).not.toHaveBeenCalledWith(
|
||||||
|
10
dist/cache-save/index.js
vendored
10
dist/cache-save/index.js
vendored
@ -60361,14 +60361,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
||||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
||||||
};
|
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
exports.run = void 0;
|
exports.run = void 0;
|
||||||
const core = __importStar(__nccwpck_require__(2186));
|
const core = __importStar(__nccwpck_require__(2186));
|
||||||
const cache = __importStar(__nccwpck_require__(7799));
|
const cache = __importStar(__nccwpck_require__(7799));
|
||||||
const fs_1 = __importDefault(__nccwpck_require__(7147));
|
|
||||||
const constants_1 = __nccwpck_require__(9042);
|
const constants_1 = __nccwpck_require__(9042);
|
||||||
const cache_utils_1 = __nccwpck_require__(1678);
|
const cache_utils_1 = __nccwpck_require__(1678);
|
||||||
// Catch and log any unhandled exceptions. These exceptions can leak out of the uploadChunk method in
|
// Catch and log any unhandled exceptions. These exceptions can leak out of the uploadChunk method in
|
||||||
@ -60381,7 +60377,7 @@ process.on('uncaughtException', e => {
|
|||||||
function run() {
|
function run() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
try {
|
try {
|
||||||
const cacheLock = core.getInput('cache');
|
const cacheLock = core.getState(constants_1.State.CachePackageManager);
|
||||||
yield cachePackages(cacheLock);
|
yield cachePackages(cacheLock);
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
@ -60393,8 +60389,7 @@ exports.run = run;
|
|||||||
const cachePackages = (packageManager) => __awaiter(void 0, void 0, void 0, function* () {
|
const cachePackages = (packageManager) => __awaiter(void 0, void 0, void 0, function* () {
|
||||||
const state = core.getState(constants_1.State.CacheMatchedKey);
|
const state = core.getState(constants_1.State.CacheMatchedKey);
|
||||||
const primaryKey = core.getState(constants_1.State.CachePrimaryKey);
|
const primaryKey = core.getState(constants_1.State.CachePrimaryKey);
|
||||||
let cachePaths = JSON.parse(core.getState(constants_1.State.CachePaths) || '[]');
|
const cachePaths = JSON.parse(core.getState(constants_1.State.CachePaths) || '[]');
|
||||||
cachePaths = cachePaths.filter(fs_1.default.existsSync);
|
|
||||||
const packageManagerInfo = yield cache_utils_1.getPackageManagerInfo(packageManager);
|
const packageManagerInfo = yield cache_utils_1.getPackageManagerInfo(packageManager);
|
||||||
if (!packageManagerInfo) {
|
if (!packageManagerInfo) {
|
||||||
core.debug(`Caching for '${packageManager}' is not supported`);
|
core.debug(`Caching for '${packageManager}' is not supported`);
|
||||||
@ -60692,6 +60687,7 @@ var LockType;
|
|||||||
})(LockType = exports.LockType || (exports.LockType = {}));
|
})(LockType = exports.LockType || (exports.LockType = {}));
|
||||||
var State;
|
var State;
|
||||||
(function (State) {
|
(function (State) {
|
||||||
|
State["CachePackageManager"] = "SETUP_NODE_CACHE_PACKAGE_MANAGER";
|
||||||
State["CachePrimaryKey"] = "CACHE_KEY";
|
State["CachePrimaryKey"] = "CACHE_KEY";
|
||||||
State["CacheMatchedKey"] = "CACHE_RESULT";
|
State["CacheMatchedKey"] = "CACHE_RESULT";
|
||||||
State["CachePaths"] = "CACHE_PATHS";
|
State["CachePaths"] = "CACHE_PATHS";
|
||||||
|
3
dist/setup/index.js
vendored
3
dist/setup/index.js
vendored
@ -71479,6 +71479,7 @@ var LockType;
|
|||||||
})(LockType = exports.LockType || (exports.LockType = {}));
|
})(LockType = exports.LockType || (exports.LockType = {}));
|
||||||
var State;
|
var State;
|
||||||
(function (State) {
|
(function (State) {
|
||||||
|
State["CachePackageManager"] = "SETUP_NODE_CACHE_PACKAGE_MANAGER";
|
||||||
State["CachePrimaryKey"] = "CACHE_KEY";
|
State["CachePrimaryKey"] = "CACHE_KEY";
|
||||||
State["CacheMatchedKey"] = "CACHE_RESULT";
|
State["CacheMatchedKey"] = "CACHE_RESULT";
|
||||||
State["CachePaths"] = "CACHE_PATHS";
|
State["CachePaths"] = "CACHE_PATHS";
|
||||||
@ -72209,6 +72210,7 @@ const cache_restore_1 = __nccwpck_require__(9517);
|
|||||||
const cache_utils_1 = __nccwpck_require__(1678);
|
const cache_utils_1 = __nccwpck_require__(1678);
|
||||||
const installer_factory_1 = __nccwpck_require__(5617);
|
const installer_factory_1 = __nccwpck_require__(5617);
|
||||||
const util_1 = __nccwpck_require__(2629);
|
const util_1 = __nccwpck_require__(2629);
|
||||||
|
const constants_1 = __nccwpck_require__(9042);
|
||||||
function run() {
|
function run() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
try {
|
try {
|
||||||
@ -72249,6 +72251,7 @@ function run() {
|
|||||||
auth.configAuthentication(registryUrl, alwaysAuth);
|
auth.configAuthentication(registryUrl, alwaysAuth);
|
||||||
}
|
}
|
||||||
if (cache && cache_utils_1.isCacheFeatureAvailable()) {
|
if (cache && cache_utils_1.isCacheFeatureAvailable()) {
|
||||||
|
core.saveState(constants_1.State.CachePackageManager, cache);
|
||||||
const cacheDependencyPath = core.getInput('cache-dependency-path');
|
const cacheDependencyPath = core.getInput('cache-dependency-path');
|
||||||
yield cache_restore_1.restoreCache(cache, cacheDependencyPath);
|
yield cache_restore_1.restoreCache(cache, cacheDependencyPath);
|
||||||
}
|
}
|
||||||
|
12
package-lock.json
generated
12
package-lock.json
generated
@ -6291,9 +6291,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/word-wrap": {
|
"node_modules/word-wrap": {
|
||||||
"version": "1.2.3",
|
"version": "1.2.4",
|
||||||
"resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz",
|
"resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.4.tgz",
|
||||||
"integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==",
|
"integrity": "sha512-2V81OA4ugVo5pRo46hAoD2ivUJx8jXmWXfUkY4KFNw0hEptvN0QfH3K4nHiwzGeKl5rFKedV48QVoqYavy4YpA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=0.10.0"
|
"node": ">=0.10.0"
|
||||||
@ -11213,9 +11213,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"word-wrap": {
|
"word-wrap": {
|
||||||
"version": "1.2.3",
|
"version": "1.2.4",
|
||||||
"resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz",
|
"resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.4.tgz",
|
||||||
"integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==",
|
"integrity": "sha512-2V81OA4ugVo5pRo46hAoD2ivUJx8jXmWXfUkY4KFNw0hEptvN0QfH3K4nHiwzGeKl5rFKedV48QVoqYavy4YpA==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"wrap-ansi": {
|
"wrap-ansi": {
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
import * as cache from '@actions/cache';
|
import * as cache from '@actions/cache';
|
||||||
|
|
||||||
import fs from 'fs';
|
|
||||||
|
|
||||||
import {State} from './constants';
|
import {State} from './constants';
|
||||||
import {getPackageManagerInfo} from './cache-utils';
|
import {getPackageManagerInfo} from './cache-utils';
|
||||||
|
|
||||||
@ -16,7 +14,7 @@ process.on('uncaughtException', e => {
|
|||||||
|
|
||||||
export async function run() {
|
export async function run() {
|
||||||
try {
|
try {
|
||||||
const cacheLock = core.getInput('cache');
|
const cacheLock = core.getState(State.CachePackageManager);
|
||||||
await cachePackages(cacheLock);
|
await cachePackages(cacheLock);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
core.setFailed(error.message);
|
core.setFailed(error.message);
|
||||||
@ -26,10 +24,9 @@ export async function run() {
|
|||||||
const cachePackages = async (packageManager: string) => {
|
const cachePackages = async (packageManager: string) => {
|
||||||
const state = core.getState(State.CacheMatchedKey);
|
const state = core.getState(State.CacheMatchedKey);
|
||||||
const primaryKey = core.getState(State.CachePrimaryKey);
|
const primaryKey = core.getState(State.CachePrimaryKey);
|
||||||
let cachePaths = JSON.parse(
|
const cachePaths = JSON.parse(
|
||||||
core.getState(State.CachePaths) || '[]'
|
core.getState(State.CachePaths) || '[]'
|
||||||
) as string[];
|
) as string[];
|
||||||
cachePaths = cachePaths.filter(fs.existsSync);
|
|
||||||
|
|
||||||
const packageManagerInfo = await getPackageManagerInfo(packageManager);
|
const packageManagerInfo = await getPackageManagerInfo(packageManager);
|
||||||
if (!packageManagerInfo) {
|
if (!packageManagerInfo) {
|
||||||
|
@ -5,6 +5,7 @@ export enum LockType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export enum State {
|
export enum State {
|
||||||
|
CachePackageManager = 'SETUP_NODE_CACHE_PACKAGE_MANAGER',
|
||||||
CachePrimaryKey = 'CACHE_KEY',
|
CachePrimaryKey = 'CACHE_KEY',
|
||||||
CacheMatchedKey = 'CACHE_RESULT',
|
CacheMatchedKey = 'CACHE_RESULT',
|
||||||
CachePaths = 'CACHE_PATHS'
|
CachePaths = 'CACHE_PATHS'
|
||||||
|
@ -9,6 +9,7 @@ import {restoreCache} from './cache-restore';
|
|||||||
import {isCacheFeatureAvailable} from './cache-utils';
|
import {isCacheFeatureAvailable} from './cache-utils';
|
||||||
import {getNodejsDistribution} from './distributions/installer-factory';
|
import {getNodejsDistribution} from './distributions/installer-factory';
|
||||||
import {parseNodeVersionFile, printEnvDetailsAndSetOutput} from './util';
|
import {parseNodeVersionFile, printEnvDetailsAndSetOutput} from './util';
|
||||||
|
import {State} from './constants';
|
||||||
|
|
||||||
export async function run() {
|
export async function run() {
|
||||||
try {
|
try {
|
||||||
@ -60,6 +61,7 @@ export async function run() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (cache && isCacheFeatureAvailable()) {
|
if (cache && isCacheFeatureAvailable()) {
|
||||||
|
core.saveState(State.CachePackageManager, cache);
|
||||||
const cacheDependencyPath = core.getInput('cache-dependency-path');
|
const cacheDependencyPath = core.getInput('cache-dependency-path');
|
||||||
await restoreCache(cache, cacheDependencyPath);
|
await restoreCache(cache, cacheDependencyPath);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user