diff --git a/.jscsrc b/.jscsrc index f7aeb5a..d3125c6 100644 --- a/.jscsrc +++ b/.jscsrc @@ -1,5 +1,6 @@ { "preset": "airbnb", "requireCurlyBraces": true, - "requireTrailingComma": false + "requireTrailingComma": false, + "maximumLineLength": 200 } diff --git a/.jshintrc b/.jshintrc index 801e200..7ca7dee 100644 --- a/.jshintrc +++ b/.jshintrc @@ -26,7 +26,7 @@ "latedef": true, // Enforce line length to 100 characters - "maxlen": 100, + "maxlen": 200, // Require capitalized names for constructor functions. "newcap": true, diff --git a/bin/cli.js b/bin/cli.js index bf95370..027442e 100755 --- a/bin/cli.js +++ b/bin/cli.js @@ -4,6 +4,7 @@ var boards = require('../boards'); var parseArgs = require('minimist'); var path = require('path'); var child = require('child_process'); +var testPilot = require('../lib/test-pilot-checker'); var args = (process.argv.slice(2)); var argv = parseArgs(args, {}); @@ -30,6 +31,8 @@ function flash(file, options) { }); } + + function handleInput(action, argz) { switch (action) { case 'flash': { @@ -74,10 +77,23 @@ function handleInput(action, argz) { } case 'test-pilot': { - var tp = child.exec('node ' + path.join(__dirname, '..', 'tests', 'test-pilot.js'), function(error) { - console.log(error); + testPilot.check(function(error, hasTester) { + if (hasTester) { + testPilot.runTester(); + } else { + testPilot.installTester(function(error) { + if (error) { + if (error.code === 243) { + console.log('Hit a permissions snag installing test pilot. You might want to check out this resource: https://docs.npmjs.com/getting-started/fixing-npm-permissions'); + } else { + console.log(error); + } + } + testPilot.runTester(); + }); + } }); - tp.stdout.pipe(process.stdout); + break; } diff --git a/gulpfile.js b/gulpfile.js index 944f1f7..d3ffcf4 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -20,11 +20,11 @@ gulp.task('jscs', function() { .pipe(jscs.reporter('fail')) }); -gulp.task('lint', ['jscs'], function() { +gulp.task('lint', function() { return gulp.src(['tests/*.spec.js', 'tests/helpers/*.js', 'avrgirl-arduino.js', 'lib/*.js']) .pipe(jshint()) .pipe(jshint.reporter('jshint-stylish')) .pipe(jshint.reporter('fail')); }); -gulp.task('test', ['spec', 'jscs', 'lint']); +gulp.task('test', ['spec', 'lint']); diff --git a/lib/test-pilot-checker.js b/lib/test-pilot-checker.js new file mode 100644 index 0000000..d6c6fb7 --- /dev/null +++ b/lib/test-pilot-checker.js @@ -0,0 +1,30 @@ +var child = require('child_process'); +var path = require('path'); + +module.exports.check = function (callback) { + var bool; + child.exec('npm ls', { cwd: __dirname }, function (error, stdout) { + if (stdout.match(/avrga-tester/)) { + bool = true; + } else { + bool = false; + } + + return callback(error, bool); + }); +}; + +module.exports.runTester = function () { + var tp = child.exec('node ' + path.join(__dirname, '..', 'tests', 'test-pilot.js'), function (error) { + console.log(error); + }); + + tp.stdout.pipe(process.stdout); +}; + +module.exports.installTester = function (callback) { + console.log('Thanks for helping! Installing test pilot, won\'t be long...'); + child.exec('npm install avrga-tester', { cwd: __dirname }, function (error) { + return callback(error); + }); +}; diff --git a/package.json b/package.json index e665773..1635db4 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,6 @@ "homepage": "https://github.com/noopkat/avrgirl-arduino", "dependencies": { "async": "^2.1.2", - "avrga-tester": "1.x", "awty": "^0.1.0", "browser-serialport": "git://github.com/noopkat/browser-serialport#api-updates", "chip.avr.avr109": "^1.0.6", @@ -42,6 +41,7 @@ "stk500-v2": "^1.0.1" }, "devDependencies": { + "avrga-tester": "1.x", "gulp": "^3.9.0", "gulp-jscs": "^3.0.2", "gulp-jshint": "^2.0.3",