mirror of
https://github.com/dawidd6/action-send-mail.git
synced 2024-11-14 07:41:06 +07:00
94 lines
4.4 KiB
JavaScript
94 lines
4.4 KiB
JavaScript
"use strict";
|
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
if (k2 === undefined) k2 = k;
|
|
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
}) : (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.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
__setModuleDefault(result, mod);
|
|
return result;
|
|
};
|
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
});
|
|
};
|
|
var __asyncValues = (this && this.__asyncValues) || function (o) {
|
|
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
var m = o[Symbol.asyncIterator], i;
|
|
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
|
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
};
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.hashFiles = void 0;
|
|
const crypto = __importStar(require("crypto"));
|
|
const core = __importStar(require("@actions/core"));
|
|
const fs = __importStar(require("fs"));
|
|
const stream = __importStar(require("stream"));
|
|
const util = __importStar(require("util"));
|
|
const path = __importStar(require("path"));
|
|
function hashFiles(globber) {
|
|
var e_1, _a;
|
|
var _b;
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
let hasMatch = false;
|
|
const githubWorkspace = (_b = process.env['GITHUB_WORKSPACE']) !== null && _b !== void 0 ? _b : process.cwd();
|
|
const result = crypto.createHash('sha256');
|
|
let count = 0;
|
|
try {
|
|
for (var _c = __asyncValues(globber.globGenerator()), _d; _d = yield _c.next(), !_d.done;) {
|
|
const file = _d.value;
|
|
core.debug(file);
|
|
if (!file.startsWith(`${githubWorkspace}${path.sep}`)) {
|
|
core.debug(`Ignore '${file}' since it is not under GITHUB_WORKSPACE.`);
|
|
continue;
|
|
}
|
|
if (fs.statSync(file).isDirectory()) {
|
|
core.debug(`Skip directory '${file}'.`);
|
|
continue;
|
|
}
|
|
const hash = crypto.createHash('sha256');
|
|
const pipeline = util.promisify(stream.pipeline);
|
|
yield pipeline(fs.createReadStream(file), hash);
|
|
result.write(hash.digest());
|
|
count++;
|
|
if (!hasMatch) {
|
|
hasMatch = true;
|
|
}
|
|
}
|
|
}
|
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
finally {
|
|
try {
|
|
if (_d && !_d.done && (_a = _c.return)) yield _a.call(_c);
|
|
}
|
|
finally { if (e_1) throw e_1.error; }
|
|
}
|
|
result.end();
|
|
if (hasMatch) {
|
|
core.debug(`Found ${count} files to hash.`);
|
|
return result.digest('hex');
|
|
}
|
|
else {
|
|
core.debug(`No matches found for glob`);
|
|
return '';
|
|
}
|
|
});
|
|
}
|
|
exports.hashFiles = hashFiles;
|
|
//# sourceMappingURL=internal-hash-files.js.map
|