mirror of
https://github.com/mshick/add-pr-comment.git
synced 2025-12-31 14:20:32 +11:00
new build
This commit is contained in:
parent
4a541a260f
commit
73ffb32342
4 changed files with 3888 additions and 1216 deletions
68
lib/util.js
Normal file
68
lib/util.js
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
"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;
|
||||
Loading…
Add table
Add a link
Reference in a new issue