mirror of
https://github.com/actions/setup-node.git
synced 2025-06-30 14:43:48 +00:00
Add project-dir
This commit is contained in:
parent
5b32c9063c
commit
318f863611
4 changed files with 71 additions and 14 deletions
24
dist/cache-save/index.js
vendored
24
dist/cache-save/index.js
vendored
|
@ -59244,11 +59244,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|||
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 }));
|
||||
exports.isCacheFeatureAvailable = exports.isGhes = exports.getCacheDirectoryPath = exports.getPackageManagerInfo = exports.getCommandOutput = exports.supportedPackageManagers = void 0;
|
||||
const core = __importStar(__nccwpck_require__(2186));
|
||||
const exec = __importStar(__nccwpck_require__(1514));
|
||||
const cache = __importStar(__nccwpck_require__(7799));
|
||||
const path_1 = __importDefault(__nccwpck_require__(1017));
|
||||
exports.supportedPackageManagers = {
|
||||
npm: {
|
||||
lockFilePatterns: ['package-lock.json', 'npm-shrinkwrap.json', 'yarn.lock'],
|
||||
|
@ -59267,8 +59271,8 @@ exports.supportedPackageManagers = {
|
|||
getCacheFolderCommand: 'yarn config get cacheFolder'
|
||||
}
|
||||
};
|
||||
const getCommandOutput = (toolCommand) => __awaiter(void 0, void 0, void 0, function* () {
|
||||
let { stdout, stderr, exitCode } = yield exec.getExecOutput(toolCommand, undefined, { ignoreReturnCode: true });
|
||||
const getCommandOutput = (toolCommand, cwd) => __awaiter(void 0, void 0, void 0, function* () {
|
||||
let { stdout, stderr, exitCode } = yield exec.getExecOutput(toolCommand, undefined, Object.assign({ ignoreReturnCode: true }, (cwd !== null && { cwd })));
|
||||
if (exitCode) {
|
||||
stderr = !stderr.trim()
|
||||
? `The '${toolCommand}' command failed with exit code: ${exitCode}`
|
||||
|
@ -59278,8 +59282,20 @@ const getCommandOutput = (toolCommand) => __awaiter(void 0, void 0, void 0, func
|
|||
return stdout.trim();
|
||||
});
|
||||
exports.getCommandOutput = getCommandOutput;
|
||||
const getPackageManagerWorkingDir = () => {
|
||||
const projectDir = core.getInput('project-dir');
|
||||
if (projectDir) {
|
||||
return projectDir;
|
||||
}
|
||||
const cache = core.getInput('cache');
|
||||
if (cache !== 'yarn') {
|
||||
return null;
|
||||
}
|
||||
const cacheDependencyPath = core.getInput('cache-dependency-path');
|
||||
return cacheDependencyPath ? path_1.default.dirname(cacheDependencyPath) : null;
|
||||
};
|
||||
const getPackageManagerVersion = (packageManager, command) => __awaiter(void 0, void 0, void 0, function* () {
|
||||
const stdOut = yield exports.getCommandOutput(`${packageManager} ${command}`);
|
||||
const stdOut = yield exports.getCommandOutput(`${packageManager} ${command}`, getPackageManagerWorkingDir());
|
||||
if (!stdOut) {
|
||||
throw new Error(`Could not retrieve version of ${packageManager}`);
|
||||
}
|
||||
|
@ -59308,7 +59324,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);
|
||||
const stdOut = yield exports.getCommandOutput(packageManagerInfo.getCacheFolderCommand, getPackageManagerWorkingDir());
|
||||
if (!stdOut) {
|
||||
throw new Error(`Could not get cache folder path for ${packageManager}`);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue