Skip to content

Commit

Permalink
Fix find lock file
Browse files Browse the repository at this point in the history
  • Loading branch information
dsame committed Apr 11, 2023
1 parent 1bcf647 commit bc0e3db
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
7 changes: 4 additions & 3 deletions dist/cache-save/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -61140,7 +61140,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.isCacheFeatureAvailable = exports.isGhes = exports.getCacheDirectoryPath = exports.getPackageManagerInfo = exports.getCommandOutput = exports.supportedPackageManagers = void 0;
exports.isCacheFeatureAvailable = exports.isGhes = exports.getCacheDirectoryPath = exports.getPackageManagerInfo = exports.getPackageManagerWorkingDir = exports.getCommandOutput = exports.supportedPackageManagers = void 0;
const core = __importStar(__nccwpck_require__(2186));
const exec = __importStar(__nccwpck_require__(1514));
const cache = __importStar(__nccwpck_require__(7799));
Expand Down Expand Up @@ -61186,8 +61186,9 @@ const getPackageManagerWorkingDir = () => {
const cacheDependencyPath = core.getInput('cache-dependency-path');
return cacheDependencyPath ? path_1.default.dirname(cacheDependencyPath) : null;
};
exports.getPackageManagerWorkingDir = getPackageManagerWorkingDir;
const getPackageManagerVersion = (packageManager, command) => __awaiter(void 0, void 0, void 0, function* () {
const stdOut = yield exports.getCommandOutput(`${packageManager} ${command}`, getPackageManagerWorkingDir());
const stdOut = yield exports.getCommandOutput(`${packageManager} ${command}`, exports.getPackageManagerWorkingDir());
if (!stdOut) {
throw new Error(`Could not retrieve version of ${packageManager}`);
}
Expand Down Expand Up @@ -61216,7 +61217,7 @@ const getPackageManagerInfo = (packageManager) => __awaiter(void 0, void 0, void
});
exports.getPackageManagerInfo = getPackageManagerInfo;
const getCacheDirectoryPath = (packageManagerInfo, packageManager) => __awaiter(void 0, void 0, void 0, function* () {
const stdOut = yield exports.getCommandOutput(packageManagerInfo.getCacheFolderCommand, getPackageManagerWorkingDir());
const stdOut = yield exports.getCommandOutput(packageManagerInfo.getCacheFolderCommand, exports.getPackageManagerWorkingDir());
if (!stdOut) {
throw new Error(`Could not get cache folder path for ${packageManager}`);
}
Expand Down
9 changes: 5 additions & 4 deletions dist/setup/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -73059,7 +73059,7 @@ const restoreCache = (packageManager, cacheDependencyPath) => __awaiter(void 0,
exports.restoreCache = restoreCache;
const findLockFile = (packageManager) => {
const lockFiles = packageManager.lockFilePatterns;
const workspace = process.env.GITHUB_WORKSPACE;
const workspace = cache_utils_1.getPackageManagerWorkingDir() || process.env.GITHUB_WORKSPACE;
const rootContent = fs_1.default.readdirSync(workspace);
const lockFile = lockFiles.find(item => rootContent.includes(item));
if (!lockFile) {
Expand Down Expand Up @@ -73108,7 +73108,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.isCacheFeatureAvailable = exports.isGhes = exports.getCacheDirectoryPath = exports.getPackageManagerInfo = exports.getCommandOutput = exports.supportedPackageManagers = void 0;
exports.isCacheFeatureAvailable = exports.isGhes = exports.getCacheDirectoryPath = exports.getPackageManagerInfo = exports.getPackageManagerWorkingDir = exports.getCommandOutput = exports.supportedPackageManagers = void 0;
const core = __importStar(__nccwpck_require__(2186));
const exec = __importStar(__nccwpck_require__(1514));
const cache = __importStar(__nccwpck_require__(7799));
Expand Down Expand Up @@ -73154,8 +73154,9 @@ const getPackageManagerWorkingDir = () => {
const cacheDependencyPath = core.getInput('cache-dependency-path');
return cacheDependencyPath ? path_1.default.dirname(cacheDependencyPath) : null;
};
exports.getPackageManagerWorkingDir = getPackageManagerWorkingDir;
const getPackageManagerVersion = (packageManager, command) => __awaiter(void 0, void 0, void 0, function* () {
const stdOut = yield exports.getCommandOutput(`${packageManager} ${command}`, getPackageManagerWorkingDir());
const stdOut = yield exports.getCommandOutput(`${packageManager} ${command}`, exports.getPackageManagerWorkingDir());
if (!stdOut) {
throw new Error(`Could not retrieve version of ${packageManager}`);
}
Expand Down Expand Up @@ -73184,7 +73185,7 @@ const getPackageManagerInfo = (packageManager) => __awaiter(void 0, void 0, void
});
exports.getPackageManagerInfo = getPackageManagerInfo;
const getCacheDirectoryPath = (packageManagerInfo, packageManager) => __awaiter(void 0, void 0, void 0, function* () {
const stdOut = yield exports.getCommandOutput(packageManagerInfo.getCacheFolderCommand, getPackageManagerWorkingDir());
const stdOut = yield exports.getCommandOutput(packageManagerInfo.getCacheFolderCommand, exports.getPackageManagerWorkingDir());
if (!stdOut) {
throw new Error(`Could not get cache folder path for ${packageManager}`);
}
Expand Down
4 changes: 3 additions & 1 deletion src/cache-restore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {State} from './constants';
import {
getCacheDirectoryPath,
getPackageManagerInfo,
getPackageManagerWorkingDir,
PackageManagerInfo
} from './cache-utils';

Expand Down Expand Up @@ -55,7 +56,8 @@ export const restoreCache = async (

const findLockFile = (packageManager: PackageManagerInfo) => {
const lockFiles = packageManager.lockFilePatterns;
const workspace = process.env.GITHUB_WORKSPACE!;
const workspace =
getPackageManagerWorkingDir() || process.env.GITHUB_WORKSPACE!;
const rootContent = fs.readdirSync(workspace);

const lockFile = lockFiles.find(item => rootContent.includes(item));
Expand Down
2 changes: 1 addition & 1 deletion src/cache-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const getCommandOutput = async (
return stdout.trim();
};

const getPackageManagerWorkingDir = (): string | null => {
export const getPackageManagerWorkingDir = (): string | null => {
const projectDir = core.getInput('project-dir');
if (projectDir) {
return projectDir;
Expand Down

0 comments on commit bc0e3db

Please sign in to comment.