UNPKG

makit

Version:

Make in JavaScript done right!

40 lines (39 loc) 1.16 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Rule = void 0; const inspect = Symbol.for('nodejs.util.inspect.custom') || 'inspect'; class Rule { constructor(target, prerequisites, recipe) { this.hasDynamicDependencies = false; this.target = target; this.prerequisites = prerequisites; this.recipe = recipe; } match(targetFile) { return this.target.exec(targetFile); } [inspect]() { let str = '\n'; /** * Symbols are not allowed to index an object, * we need `suppressImplicitAnyIndexErrors` to suppress errors. * * see: https://github.com/microsoft/TypeScript/issues/1863 */ str += this.target[inspect]() + ':'; const deps = this.prerequisites[inspect](); if (deps) { str += ' ' + deps; } if (this.hasDynamicDependencies) { if (deps) { str += ','; } str += ' [...dynamic]'; } str += '\n'; str += ' ' + this.recipe[inspect](); return str; } } exports.Rule = Rule;