function createParser(filename) { var parserPath = require.resolve('bengine/js/benji.pegjs'); var parserSrc = fs.readFileSync(parserPath, 'utf8'); var parser; loophole.allowUnsafeEval(function () { parser = pegjs.buildParser(parserSrc); }); parser.simplify = simplify; return parser; }
var txt = fs.readFile(main.currentFile, 'utf8', function (err, data) { if (err) { return console.log(err); } var mod; unsafe(function () { mod = eval(data); }); console.log(main.inputsPanel.inputs.textContent); console.log(mod.run(main.inputsPanel.inputs.textContent)); });
return new Promise((resolve, reject) => { let returnValue = []; const text = editor.getText(); const path = editor.getPath(); if(!shouldLint(path)){ return resolve(returnValue); } if(_.some(atom.config.get("mdtkit-lint").ignoreImportOnlyFiles, ignoreLabel => text.startsWith(ignoreLabel))){ return resolve(returnValue); } try{ const result = allowUnsafeEval(() => MDTKitParser.instance.parseText(text, path)); if(atom.config.get("mdtkit-lint").showTooltipForResolvedValues){ returnValue = returnValue.concat(traceResolvedValues(result.tests)); } _.each(result.linter.errors, error => { returnValue.push({ type: 'Error', text: error.message, filePath: error.path, range: new Range( [error.location.start.line-1, error.location.start.column-1], [error.location.end.line-1, error.location.end.column-1] ) }); }); _.each(result.linter.stack, stackElem => { returnValue.push({ type: 'Error', text: `Parsing failed on \'${_.first(stackElem.blockName.split('_'))}\'`, filePath: stackElem.path, range: new Range( [stackElem.location.start.line-1, stackElem.location.start.column-1], [stackElem.location.end.line-1, stackElem.location.end.column-1] ) }); }); return resolve(returnValue); }catch(e){ returnValue.push({ type: 'Error', text: "A critical error occurred: " + e.message }); } return resolve(returnValue); });
var execFile = require('child_process').execFile; var loophole = require('loophole'); var flow = loophole.allowUnsafeEval(function () { return loophole.allowUnsafeNewFunction(function () { return require('flow-bin'); }); }); module.exports = { activate: function () { var self = this; atom.workspaceView.command('flow:check', function () { self.check('hi'); }); }, /* @flow */ check: function (type: number) { var test = type * 5; var initialDirectory = atom.project.getPath() ? atom.project.getPath() : '~'; // This assumes the active pane item is an editor var editor = atom.workspace.getActivePaneItem(); //editor.insertText('Hello, World!'); execFile(flow, ['check'], { cwd: initialDirectory }, function (err, stdout, stderr) { console.error(err); if (err) { throw new Error('flow:check error: ' + err); }
module.exports = function (args) { allowUnsafeEval(() => { return allowUnsafeNewFunction(() => { document.body.style.overflowY = 'scroll'; let element = document.createElement('div'); element.id = 'mocha'; document.body.appendChild(element); let fileref = document.createElement("link"); fileref.setAttribute("rel", "stylesheet"); fileref.setAttribute("type", "text/css"); fileref.setAttribute("href", path.join(__dirname, 'node_modules/mocha/mocha.css')); document.getElementsByTagName("head")[0].appendChild(fileref); let applicationDelegate = args.buildDefaultApplicationDelegate(); // Build atom global window.atom = args.buildAtomEnvironment({ applicationDelegate: applicationDelegate, window: window, document: document, configDirPath: process.env.ATOM_HOME, enablePersistence: false }); // Instantiate a Mocha instance. let mocha = new Mocha({ reporter: 'html' }); let testDir = path.join(__dirname, 'spec'); // Add each .js file to the mocha instance fs.readdirSync(path.join(testDir, 'unit')).filter(function(file){ // Only keep the .js files return file.substr(-3) === '.js'; }).forEach(function(file){ mocha.addFile( path.join(testDir, 'unit', file) ); }); fs.readdirSync(path.join(testDir, 'functional')).filter(function(file){ // Only keep the .js files return file.substr(-3) === '.js'; }).forEach(function(file){ mocha.addFile( path.join(testDir, 'functional', file) ); }); // mocha.checkLeaks(); // Run the tests. mocha.run((failures, a) => { process.on('exit', () => { process.exit(failures); // exit with non-zero status if there were failures }); }); }); }); // success return Promise.resolve(0); };
let parser try { parser = require('./snippet-body') } catch (error) { const {allowUnsafeEval} = require('loophole') const fs = require('fs-plus') const PEG = require('pegjs') const grammarSrc = fs.readFileSync(require.resolve('./snippet-body.pegjs'), 'utf8') parser = null allowUnsafeEval(() => parser = PEG.buildParser(grammarSrc)) } module.exports = parser