Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function runTest(test) {
var batchFile = path.join(test.path, 'run.batch');
if (!fs.existsSync(batchFile)) {
runNextTest();
return; // this folder is not a test folder;
}
var txt = (fs.readFileSync(batchFile) + '');
txt = applyChanges(txt);
console.log(colors.bold('running'), txt);
rimraf.sync(test.path);
try {
execSync(`git checkout ${test.path} && cd ${test.path} && ${txt}`, {stdio:[0,1,2]});
totals.success++;
console.log(' -', colors.bold('pass'), currentTest.name);
} catch(err) {
totals.fail++;
console.log(' -', colors.bold('failed'), currentTest.name);
console.error(err.message);
process.exit(1);
}
runNextTest();
}
exports.buildCommands = function arduinoBuild(config, runCmd, command, compile_path, mount_path) {
var target_board = config.target;
var callback = null;
var runString = '';
var pathName = FIX_PATH_CONTAINER(path.relative(mount_path, compile_path));
if (config && !config.filename) {
if (command == 'compile' || command == 'export') {
var files = fs.readdirSync(compile_path);
for (let file of files) {
if (path.extname(file).toLowerCase() == '.ino') {
console.log(' -', colors.bold('warning'));
console.log(' -', 'picked', colors.bold(file), ' automatically as a project file');
console.log(' -', 'you can define it from \'iotz.json\' \'filename\'');
config.filename = file;
break;
}
}
}
}
if (command == 'init') {
// noop
} else if (command == 'localFolderContainerConstructer') {
var install_board = '';
var boardFound = false;
// search for the board from command args
if (typeof runCmd === 'string' && runCmd.length && target_board != runCmd) {
input += ch;
}
}
else {
console.error('Internal Error (not your fault): Unexpected Expiration Format: ' + format);
process.exit(1);
}
prevc = c;
});
if (arr.length) {
input += '/' + arr.join('');
}
part = format.substr(input.length);
complete = colors.bold(input) + colors.dim(part);
ws.cursorTo(0);
writePrompt(ws, state);
ws.write(complete);
ws.moveCursor(-1 * part.length, 0);
}
import { getVersion } from './helpers/general';
program
.version(getVersion())
.command('init [template] [version]', 'init a new project')
.command('build [options] [config]', 'build the current project')
.command('dev [options] [config]', 'start the current project in dev mode')
.command('start [options] [config]', 'start the current project')
.parse(process.argv);
if (!program.runningCommand) {
console.log(colors.red(`Invalid command: ${colors.bold(program.args[0])}\n`));
}
require('./helpers/subcommand-fix')(program);
function exitHandler(options, err) {
if (err) {
if (err.stack) {
console.error(err.stack);
} else {
console.error(err.toString());
}
}
if (whitelistedVulnerabilities.length > 0) {
logger.info(colors.bold.yellow("Filtering the following vulnerabilities"));
logger.info(colors.bold.yellow('=================================================='));
for (var i = 0; i < whitelistedVulnerabilities.length; i++) {
var detail = whitelistedVulnerabilities[i];
logger.info(`${colors.bold.blue(detail['title'])} affected versions: ${colors.red(detail['package'])} ${colors.red(detail['versions'])}`);
logger.info(`${detail['description']}`);
logger.info(colors.bold("ID") + ": " + detail.id);
if (detail.whitelistedPaths) {
detail.whitelistedPaths.forEach(function(path) {
logger.info(colors.bold("Ignored Path") + ": " + path);
})
}
logger.info(colors.bold.yellow('=================================================='));
};
}
logger.info('');
logger.info('Audited dependencies: ' + actualAudits +
', Vulnerable: ' + colors.bold.red(vulnerabilityCount) +
', Ignored: ' + whitelistedVulnerabilities.length);
if(config.get('report')) {
var filtered = whitelistedVulnerabilities.length;
function getContextMessage(source, lineNumber, columnNumber) {
source = source.split('\n');
var lineDigits = ('' + (lineNumber + 1)).length + 1;
var padding = repeatString(' ', lineDigits);
var previousPrefix = colors.dim(pad(padding, (lineNumber - 1), true) + '| ');
var errorPrefix = colors.dim(pad(padding, lineNumber, true) + '| ');
var followingPrefix = colors.dim(pad(padding, (lineNumber + 1), true) + '| ');
var previousLine = source[lineNumber - 2] + '\n';
var errorLine = colors.bold(source[lineNumber - 1]) + '\n';
var followingLine = source[lineNumber] + '\n';
previousLine = previousLine.trim().slice(0, 2) === '//' ? colors.dim(previousLine) : previousLine;
followingLine = followingLine.trim().slice(0, 2) === '//' ? colors.dim(followingLine) : followingLine;
var previousTotal = previousLine === 'undefined\n' ? '' : previousPrefix + previousLine;
var errorTotal = errorPrefix + errorLine;
var followingTotal = followingLine === 'undefined\n' ? '' : followingPrefix + followingLine;
return previousTotal + errorTotal + (padding + getArrow(columnNumber)) + followingTotal;
}
archive.on('error', (err) => {
console.error(bold(red(`Error while creating WAR archive: ${err}`)));
});
_.mapObject(modules, (moduleData, moduleName) => {
detailsString += `\n${colors.gray(i++)} ${colors.bold(moduleName)}\n`;
if (options.modulesOnly) return;
detailsString += ` ${colors.gray('Templates')}:\n`;
if (_.isEmpty(moduleData.templates)) detailsString += ` - ${colors.gray('Nothing to show.')}\n`;
else _.mapObject(moduleData.templates, mapDescObject);
detailsString += ` ${colors.gray('Snippets')}:\n`;
if (_.isEmpty(moduleData.snippets)) detailsString += ` - ${colors.gray('Nothing to show.')}\n`;
else _.mapObject(moduleData.snippets, mapDescObject);
});
if (i === 1) detailsString += colors.gray('\nNothing to show.\n');
function displayEmailhook (hook) {
Logger.println((hook.name && colors.bold(hook.name)) || hook.id);
Logger.println(` id: ${hook.id}`);
Logger.println(` services: ${(hook.scope && hook.scope.join(', ')) || hook.ownerId}`);
Logger.println(` events: ${(hook.events && hook.events.join(', ')) || colors.bold('ALL')}`);
if (hook.notified) {
Logger.println(' to:');
hook.notified.forEach((target) => Logger.println(` ${target.target || 'whole team'}`));
}
else {
Logger.println(' to: whole team');
}
Logger.println();
}
public printSectionHeader(title: string) {
this.print(colors.underline(colors.bold(title)));
}