UNPKG

maestro-cli-roku

Version:

command line tools for maestro-roku projects

82 lines (81 loc) 3.25 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var util_1 = require("util"); var ProcessorLogLevel; (function (ProcessorLogLevel) { ProcessorLogLevel[ProcessorLogLevel["error"] = 0] = "error"; ProcessorLogLevel[ProcessorLogLevel["warning"] = 1] = "warning"; ProcessorLogLevel[ProcessorLogLevel["info"] = 2] = "info"; ProcessorLogLevel[ProcessorLogLevel["verbose"] = 3] = "verbose"; })(ProcessorLogLevel = exports.ProcessorLogLevel || (exports.ProcessorLogLevel = {})); var docsLink = "\nPlease read the docs for usage details https://github.com/georgejecook/maestro/blob/master/docs/index.md#maestro-cli"; function createProcessorConfig(config) { console.log('parsing config ' + util_1.inspect(config)); var processorConfig = config; if (!config.sourcePaths || config.sourcePaths.length === 0) { throw new Error('Config does not contain sourcePath or sourcePath property' + docsLink); } if (!config.outputPath) { throw new Error('Config does not contain outputPath property' + docsLink); } if (config.sourcePaths.find(function (p) { return p === config.outputPath; })) { throw new Error('maestro-cli can not have a matching sourcePath and outputPath. One of your sourcePaths is the same as your outputPath' + docsLink); } if (!config.logLevel) { processorConfig.logLevel = ProcessorLogLevel.info; } if (config.createRuntimeFiles === undefined) { processorConfig.createRuntimeFiles = true; } processorConfig.filePattern = getStringArrayFromString(config.filePattern); setPatternArray(processorConfig, 'filePattern', [ '**/*.bs', '**/*.brs', '**/*.xml', '!**/maestro/**/*' ]); setPatternArray(processorConfig, 'processingExcludedPaths', [ '!components/rLogComponents/**/*.*', '!source/rLog/**/*.*', '!source/tests/rooibosDist.brs', '!source/tests/rooibosFunctionMap.brs' ]); setPatternArray(processorConfig, 'nonCheckedImports', [ 'source/rLog/rLogMixin.brs', 'source/tests/rooibosDist.brs', 'source/tests/rooibosFunctionMap.brs' ]); processorConfig.nonCheckedImports = processorConfig.nonCheckedImports.map(function (path) { path = path.toLowerCase(); if (!path.startsWith('pkg:/')) { path = 'pkg:/' + path; } return path; }); return processorConfig; } exports.createProcessorConfig = createProcessorConfig; function setPatternArray(config, fieldName, defaultValue) { config[fieldName] = getStringArrayFromString(config[fieldName]); if (!config[fieldName]) { console.log('config does not specify ' + fieldName + 'using default value ' + util_1.inspect(defaultValue) + docsLink); } } function getStringArrayFromString(text) { if (text) { if (Array.isArray(text)) { return text; } try { var arrayValue = text.split(','); return arrayValue; } catch (e) { console.log('could not parse glob array - please be sure to use glob1,glob2,... format - no spaces!'); return null; } } else { return null; } }