solidity-docgen
Version:
Solidity API documentation automatic generator.
43 lines • 2.02 kB
JavaScript
// globby and its fast-glob dependency don't support backward slashes in paths,
// so we "posixify" all paths in the Filter constructor and use the
// POSIX-specific path module to ensure everything stays forward-slashed
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Filter = void 0;
const path_1 = require("path");
const globby_1 = __importDefault(require("globby"));
const micromatch_1 = __importDefault(require("micromatch"));
const memoize_1 = require("./memoize");
class Filter {
constructor(root, excludePaths = []) {
this.root = posixifyPath(root);
this.excludePaths = excludePaths.map(posixifyPath);
}
get matcher() {
return micromatch_1.default.matcher('**/*.sol', {
ignore: this.excludePaths.map(e => path_1.posix.join(path_1.posix.relative(this.root, e), '**/*')),
});
}
async glob(pattern) {
return await globby_1.default(path_1.posix.join(this.root, '**', pattern), {
ignore: this.excludePaths.map(e => path_1.posix.join(e, '**/*')),
});
}
}
__decorate([
memoize_1.memoize
], Filter.prototype, "matcher", null);
exports.Filter = Filter;
function posixifyPath(p) {
return p.replace(path_1.sep, path_1.posix.sep);
}
//# sourceMappingURL=filter.js.map
;