UNPKG

burp-brightscript

Version:

lightweight processor for roku brightscript projects

87 lines 3.59 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var Debug = require("debug"); var path = require("path"); var util_1 = require("util"); var FileDescriptor_1 = require("./FileDescriptor"); var FileProcessor_1 = require("./FileProcessor"); var debug = Debug('Burp'); var glob = require('glob-all'); var BurpProcessor = /** @class */ (function () { function BurpProcessor(config) { if (!config) { throw new Error('config is empty'); } if (!config.sourcePath) { throw new Error('sourcePath is empty'); } this._config = config; debug("Starting directory: " + process.cwd() + " sourcePath " + this._config.sourcePath); try { process.chdir(this._config.sourcePath); } catch (err) { debug('Could not change directory to source path: ' + err); throw new Error('Aborting'); } this._rootPath = process.cwd(); debug('Set working directory to : ' + process.cwd()); this._warnings = []; this._errors = []; this._config.filePattern = this._config.filePattern || ['**/*.brs']; } Object.defineProperty(BurpProcessor.prototype, "errors", { get: function () { return this._errors; }, enumerable: true, configurable: true }); Object.defineProperty(BurpProcessor.prototype, "warnings", { get: function () { return this._warnings; }, enumerable: true, configurable: true }); BurpProcessor.prototype.processFiles = function () { var _this = this; debug("Running Config is " + this._config + " "); debug("path " + this._config.sourcePath + " "); debug("rootpath " + this._rootPath + " "); var fileProcessor = new FileProcessor_1.FileProcessor(this._config); fileProcessor.rootPath = process.cwd(); var files = glob.sync(this._config.filePattern); debug(util_1.inspect(files)); files.forEach(function (file) { debug("file " + file + ", " + path.resolve(file)); var fileDescriptor = new FileDescriptor_1.default(path.dirname(path.resolve(file)), path.basename(file), path.extname(file).toLowerCase()); var result = fileProcessor.processFile(fileDescriptor); debug(" processed file " + fileDescriptor.fullPath + " result: " + result); _this.errors.concat(fileProcessor.errors); _this.warnings.concat(fileProcessor.warnings); }); this.errors.concat(this.errors); this.warnings.concat(this.warnings); this.reportErrors(); this.reportWarnings(); return this.reportErrors.length === 0; }; BurpProcessor.prototype.reportErrors = function () { if (this.errors.length > 0) { debug("\n The following errors occurred during processing:\n\n ======\n "); this.errors.forEach(function (errorText) { return debug("[ERROR] " + errorText); }); debug("\n ======\n "); } }; BurpProcessor.prototype.reportWarnings = function () { if (this.warnings.length > 0) { debug("\n The following warnings occurred during processing:\n\n ======\n "); this.warnings.forEach(function (errorText) { return debug("[WARN] " + errorText); }); debug("\n ======\n "); } }; return BurpProcessor; }()); exports.BurpProcessor = BurpProcessor; //# sourceMappingURL=BurpProcessor.js.map