semantic-release-gh
Version:
The official GitHub plugin, modified to accept repositoryUrl as a parameter
40 lines • 1.96 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.GlobAssets = void 0;
const tslib_1 = require("tslib");
const debug_1 = tslib_1.__importDefault(require("debug"));
const dir_glob_1 = tslib_1.__importDefault(require("dir-glob"));
const globby_1 = tslib_1.__importDefault(require("globby"));
const lodash_1 = require("lodash");
const node_path_1 = tslib_1.__importDefault(require("node:path"));
const debug = (0, debug_1.default)('semantic-release:github');
const GlobAssets = async ({ cwd }, assets) => (0, lodash_1.uniqWith)((await Promise.all(assets.map(async (asset) => {
let glob = (0, lodash_1.castArray)((0, lodash_1.isPlainObject)(asset) ? asset.path : asset);
glob = (0, lodash_1.uniq)([...(await (0, dir_glob_1.default)(glob, { cwd })), ...glob]);
if (glob.length <= 1 && glob[0].startsWith('!')) {
debug('skipping the negated glob %o as its alone in its group and would retrieve a large amount of files', glob[0]);
return [];
}
const globbed = await (0, globby_1.default)(glob, {
cwd,
dot: true,
expandDirectories: false,
gitignore: false,
onlyFiles: false
});
if ((0, lodash_1.isPlainObject)(asset)) {
if (globbed.length > 1) {
return globbed.map((file) => (Object.assign(Object.assign({}, asset), { name: node_path_1.default.basename(file), path: file })));
}
return Object.assign(Object.assign({}, asset), { path: globbed[0] || asset.path });
}
if (globbed.length > 0) {
return globbed;
}
return glob;
})))
.flat()
.sort((asset) => ((0, lodash_1.isPlainObject)(asset) ? -1 : 1)), (first, second) => node_path_1.default.resolve(cwd, (0, lodash_1.isPlainObject)(first) ? first.path : first) ===
node_path_1.default.resolve(cwd, (0, lodash_1.isPlainObject)(second) ? second.path : second));
exports.GlobAssets = GlobAssets;
//# sourceMappingURL=glob-assets.js.map