UNPKG

@pnp/cli-microsoft365

Version:

Manage Microsoft 365 and SharePoint Framework projects on any platform

45 lines 1.24 kB
import fs from 'fs'; import path from 'path'; import { Rule } from '../../Rule.js'; export class FileAddRemoveRule extends Rule { constructor(filePath, add, contents) { super(); this.filePath = filePath; this.add = add; this.contents = contents; this.filePath = path.normalize(this.filePath); } get title() { return this.filePath; } get description() { return `${this.add ? 'Add' : 'Remove'} file ${this.filePath}`; } get resolution() { if (this.add) { return `add_cmd[BEFOREPATH]"${this.filePath}"[AFTERPATH][BEFORECONTENT] ${this.contents} [AFTERCONTENT]`; } else { return `remove_cmd "${this.filePath}"`; } } get resolutionType() { return 'cmd'; } get severity() { return 'Required'; } get file() { return this.filePath; } visit(project, notifications) { const targetPath = path.join(project.path, this.filePath); if ((!this.add && fs.existsSync(targetPath)) || (this.add && !fs.existsSync(targetPath))) { this.addFinding(notifications); } } } //# sourceMappingURL=FileAddRemoveRule.js.map