Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
noopkat committed Nov 26, 2016
1 parent 58a92ef commit 53202c6
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 8 deletions.
3 changes: 2 additions & 1 deletion .jscsrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"preset": "airbnb",
"requireCurlyBraces": true,
"requireTrailingComma": false
"requireTrailingComma": false,
"maximumLineLength": 200
}
2 changes: 1 addition & 1 deletion .jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"latedef": true,

// Enforce line length to 100 characters
"maxlen": 100,
"maxlen": 200,

// Require capitalized names for constructor functions.
"newcap": true,
Expand Down
22 changes: 19 additions & 3 deletions bin/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, {});
Expand All @@ -30,6 +31,8 @@ function flash(file, options) {
});
}



function handleInput(action, argz) {
switch (action) {
case 'flash': {
Expand Down Expand Up @@ -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;
}

Expand Down
4 changes: 2 additions & 2 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
30 changes: 30 additions & 0 deletions lib/test-pilot-checker.js
Original file line number Diff line number Diff line change
@@ -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);
});
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down

0 comments on commit 53202c6

Please sign in to comment.