mirror of
https://github.com/mshick/add-pr-comment.git
synced 2025-12-31 06:19:53 +11:00
68 lines
2.7 KiB
JavaScript
68 lines
2.7 KiB
JavaScript
"use strict";
|
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
if (k2 === undefined) k2 = k;
|
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
}
|
|
Object.defineProperty(o, k2, desc);
|
|
}) : (function(o, m, k, k2) {
|
|
if (k2 === undefined) k2 = k;
|
|
o[k2] = m[k];
|
|
}));
|
|
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
}) : function(o, v) {
|
|
o["default"] = v;
|
|
});
|
|
var __importStar = (this && this.__importStar) || function (mod) {
|
|
if (mod && mod.__esModule) return mod;
|
|
var result = {};
|
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
__setModuleDefault(result, mod);
|
|
return result;
|
|
};
|
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
};
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.findFiles = exports.getMessageFromPaths = void 0;
|
|
const core = __importStar(require("@actions/core"));
|
|
const glob = __importStar(require("@actions/glob"));
|
|
const promises_1 = __importDefault(require("node:fs/promises"));
|
|
async function getMessageFromPaths(searchPath) {
|
|
let message = '';
|
|
const files = await findFiles(searchPath);
|
|
for (const [index, path] of files.entries()) {
|
|
if (index > 0) {
|
|
message += '\n';
|
|
}
|
|
message += await promises_1.default.readFile(path, { encoding: 'utf8' });
|
|
}
|
|
return message;
|
|
}
|
|
exports.getMessageFromPaths = getMessageFromPaths;
|
|
function getDefaultGlobOptions() {
|
|
return {
|
|
followSymbolicLinks: true,
|
|
implicitDescendants: true,
|
|
omitBrokenSymbolicLinks: true,
|
|
};
|
|
}
|
|
async function findFiles(searchPath, globOptions) {
|
|
const searchResults = [];
|
|
const globber = await glob.create(searchPath, globOptions || getDefaultGlobOptions());
|
|
const rawSearchResults = await globber.glob();
|
|
for (const searchResult of rawSearchResults) {
|
|
const fileStats = await promises_1.default.stat(searchResult);
|
|
if (!fileStats.isDirectory()) {
|
|
core.debug(`File: ${searchResult} was found using the provided searchPath`);
|
|
searchResults.push(searchResult);
|
|
}
|
|
else {
|
|
core.debug(`Removing ${searchResult} from rawSearchResults because it is a directory`);
|
|
}
|
|
}
|
|
return searchResults;
|
|
}
|
|
exports.findFiles = findFiles;
|