mirror of
https://github.com/actions/setup-node.git
synced 2025-06-30 14:43:48 +00:00
handle non-dir cache-dependency-path
This commit is contained in:
parent
813556063c
commit
a3d2aaf78f
5 changed files with 118 additions and 61 deletions
|
@ -56,8 +56,8 @@ export const restoreCache = async (
|
|||
|
||||
const findLockFile = (packageManager: PackageManagerInfo) => {
|
||||
const lockFiles = packageManager.lockFilePatterns;
|
||||
const workspace =
|
||||
getPackageManagerWorkingDir() || process.env.GITHUB_WORKSPACE!;
|
||||
const workspace = process.env.GITHUB_WORKSPACE!;
|
||||
|
||||
const rootContent = fs.readdirSync(workspace);
|
||||
|
||||
const lockFile = lockFiles.find(item => rootContent.includes(item));
|
||||
|
|
|
@ -2,6 +2,7 @@ import * as core from '@actions/core';
|
|||
import * as exec from '@actions/exec';
|
||||
import * as cache from '@actions/cache';
|
||||
import path from 'path';
|
||||
import fs from 'fs';
|
||||
|
||||
type SupportedPackageManagers = {
|
||||
[prop: string]: PackageManagerInfo;
|
||||
|
@ -58,7 +59,17 @@ export const getPackageManagerWorkingDir = (): string | null => {
|
|||
}
|
||||
|
||||
const cacheDependencyPath = core.getInput('cache-dependency-path');
|
||||
return cacheDependencyPath ? path.dirname(cacheDependencyPath) : null;
|
||||
if (!cacheDependencyPath) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const wd = path.dirname(cacheDependencyPath);
|
||||
|
||||
if (fs.existsSync(wd) && fs.lstatSync(wd).isDirectory()) {
|
||||
return wd;
|
||||
}
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
export const getPackageManagerCommandOutput = (command: string) =>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue