diff --git a/.eslintrc.yml b/.eslintrc.yml index 7d23ff50..509d5216 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -82,3 +82,7 @@ rules: no-unused-vars: - error - args: none + no-useless-escape: + - off + no-regex-spaces: + - off diff --git a/lib/runners/java.js b/lib/runners/java.js index 08621bb7..3e23bd9b 100644 --- a/lib/runners/java.js +++ b/lib/runners/java.js @@ -1,6 +1,4 @@ var shovel = require('../shovel'), - exec = require('child_process').exec, - execSync = require('child_process').execSync, util = require('../util'), tagHelpers = require('../utils/tag-helpers'), manipulateFileSync = require('../utils/manipulate-file-sync'), @@ -11,17 +9,16 @@ module.exports.run = function run(opts, cb) { let buildGradle = ''; shovel.start(opts, cb, { - solutionOnly: function (runCode, fail) { + solutionOnly: function(runCode, fail) { fs.emptydirSync(`${opts.dir}/src`); const names = extractNames(opts.solution, 'Solution'); - const solutionFile = util.codeWriteSync(null, opts.solution, `${opts.dir}/src/main/java`, names.file); - + util.codeWriteSync(null, opts.solution, `${opts.dir}/src/main/java`, names.file); util.codeWriteSync(null, javaMain(names.full), `${opts.dir}/src/test/java`, 'Start.java'); buildAndTest(runCode); }, - testIntegration: function (runCode, fail) { + testIntegration: function(runCode, fail) { fs.emptydirSync(`${opts.dir}/src`); const fixtures = []; @@ -62,7 +59,7 @@ module.exports.run = function run(opts, cb) { buildAndTest(runCode); }, - transformBuffer: function (buffer) { + transformBuffer: function(buffer) { var stdout = "", stderr = "", buildLines = []; // both types of streams will be embedded within the gradle output, so lets break them out @@ -82,9 +79,9 @@ module.exports.run = function run(opts, cb) { // attach build output to beginning of stdout, also attach dependencies so everyone knows whats available // TODO: eventually we want to support this as its own buffer property, for now we are just embedding it // within the output in case its helpful for troubleshooting - buildOutput = `Dependencies:\n\n${loadedDependencies()}\n\nTasks:\n\n`; + let buildOutput = `Dependencies:\n\n${loadedDependencies()}\n\nTasks:\n\n`; buildOutput += buildLines.join("\n").replace(/^Start > start.*/gm, ''); - buildOutput = tagHelpers.log('-Build Output', buildOutput) + buildOutput = tagHelpers.log('-Build Output', buildOutput); buffer.stdout = buildOutput + stdout; buffer.stderr += stderr; @@ -192,7 +189,7 @@ module.exports.run = function run(opts, cb) { .join('\n') + '\n'; } - function extractNames (code, defaultClassName) { + function extractNames(code, defaultClassName) { const packageName = (code.match(/\bpackage\s+([A-Z|a-z](?:[a-z|A-Z|0-9|_]|\.[A-Z|a-z])*)\W/) || [])[1]; const className = (code.match(/\bclass\s+([A-Z][a-z|A-Z|0-9|_]*)\W/) || [])[1] || defaultClassName; @@ -206,7 +203,7 @@ module.exports.run = function run(opts, cb) { // hacky solution for starting the dynamic main class. We need to use test mode since thats currently how we // have STDOUT/ERR setup to output anything - function javaMain (mainClass) { + function javaMain(mainClass) { const importClass = mainClass.indexOf('.') > 0 ? `import ${mainClass};` : ''; return ` import org.junit.Test; @@ -218,12 +215,12 @@ module.exports.run = function run(opts, cb) { ${mainClass}.main(null); } } - ` + `; } // Our hacky way of running tests with our custom listener. // TODO: this is configurable via gradle, we just need to take the time to figure that bit out. - function javaTestRunner (fixtures) { + function javaTestRunner(fixtures) { // add any imports needed, use a set to make sure we have unique values let imports = new Set(fixtures.filter(f => f.indexOf('.') > 0).map(f => `import ${f};\n`)); let runs = fixtures.map(f => `runner.run(${f}.class);\n`); @@ -242,5 +239,5 @@ module.exports.run = function run(opts, cb) { } } `; - }; -} + } +}; diff --git a/lib/utils/manipulate-file-sync.js b/lib/utils/manipulate-file-sync.js index 07654742..0db0ac4b 100644 --- a/lib/utils/manipulate-file-sync.js +++ b/lib/utils/manipulate-file-sync.js @@ -33,7 +33,7 @@ module.exports = function manipulateFileSync(src, dest, options) { fs.outputFileSync(dest, content, options.write); return content; -} +}; /** * Instead of replacing content, this method tries to determine which content should be kept @@ -45,7 +45,7 @@ module.exports = function manipulateFileSync(src, dest, options) { * @returns String transformed content */ function keep(content, options) { - const targets = options.target ? content.match(options.target) : null + const targets = options.target ? content.match(options.target) : null; let targetContent = targets && targets.length ? targets[0] : content; if (targetContent) { diff --git a/lib/utils/split-files.js b/lib/utils/split-files.js index a98f230a..91b84080 100644 --- a/lib/utils/split-files.js +++ b/lib/utils/split-files.js @@ -5,7 +5,7 @@ * @param regex defaults to a regex that supports `// @config: split-file File.ext` * @returns {{root: string, files: {}, splits: number}} */ -module.exports = function splitFiles(content, regex = /^[ \t#|\/]* ?@config[: ] ?split-file (.*$)/gm) { +module.exports = function splitFiles(content, regex = /^[ #|\/]* ?@config[: ] ?split-file (.*$)/gm) { const parts = content.split(regex), result = {root: '', files: {}, splits: 0}; @@ -26,4 +26,4 @@ module.exports = function splitFiles(content, regex = /^[ \t#|\/]* ?@config[: ] }); return result; -} +}; diff --git a/lib/utils/tag-helpers.js b/lib/utils/tag-helpers.js index e21bf257..0ea68049 100644 --- a/lib/utils/tag-helpers.js +++ b/lib/utils/tag-helpers.js @@ -1,3 +1,3 @@ module.exports.log = function log(label, value) { return `${(value || '').replace(/\n/g, "<:LF:>")}\n`; -} +}; diff --git a/lib/utils/wrap.js b/lib/utils/wrap.js index 09a1b9eb..76cc5ff4 100644 --- a/lib/utils/wrap.js +++ b/lib/utils/wrap.js @@ -1,3 +1,3 @@ module.exports = function wrap(value) { return Array.isArray(value) ? value : [value]; -} +};