Skip to content

Commit

Permalink
Merge pull request #2 from FreeAllMedia/feature/watch
Browse files Browse the repository at this point in the history
watch implementation
  • Loading branch information
nicosommi committed Aug 10, 2015
2 parents 03c5256 + c550d18 commit c7f7627
Show file tree
Hide file tree
Showing 14 changed files with 90 additions and 36 deletions.
5 changes: 5 additions & 0 deletions .bithoundrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"ignore": [
"es5/**/*.js"
]
}
9 changes: 2 additions & 7 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
# Save as .codeclimate.yml (note leading .) in project root directory
languages:
JavaScript: true
Ruby: false
PHP: false
Python: false

# exclude_paths:
# - "foo/bar.rb"
exclude_paths:
- es5/*
22 changes: 2 additions & 20 deletions .karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,31 +58,13 @@ let configOptions = {

// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: false
singleRun: true
};

/**
* Special Options For SauceLabs
*/
if (process.env.SAUCE_USERNAME) {
/**
* If SauceLabs credentials are available,
* set up the tests to run through them.
*/
configOptions.sauceLabs = {
testName: "Forbin.js"
};
const customLaunchers = require("./.sauce.json").platforms;
configOptions.customLaunchers = customLaunchers;
configOptions.browsers = Object.keys(customLaunchers);
reporters.push("saucelabs");
} else {
/**
* If there are no SauceLabs credentials available,
* detect the browsers that we *can* use.
*/
frameworks.push("detectBrowsers");
}
frameworks.push("detectBrowsers");

module.exports = function(config) {
// level of logging
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2015 Free All Media LLC
Copyright (c) 2015 Free All Media, LLC

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
4 changes: 4 additions & 0 deletions gulpfile.babel.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import "./tasks/suppress-errors.js";
import "./tasks/build-spec.js";
import "./tasks/build-spec-assets.js";
import "./tasks/build-lib.js";
import "./tasks/build-lib-assets.js";
import "./tasks/build.js";
import "./tasks/test-local.js";
import "./tasks/test-browsers.js";
import "./tasks/test.js";
import "./tasks/test-watch.js";
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,16 @@
"gulp-babel": "^5.1.0",
"gulp-istanbul": "^0.10.0",
"gulp-mocha": "^2.1.1",
"gulp-util": "^3.0.6",
"karma": "^0.12.36",
"karma-browserify": "^4.2.1",
"karma-chai": "^0.1.0",
"karma-detect-browsers": "^2.0.0",
"karma-mocha": "^0.1.10",
"karma-sauce-launcher": "^0.2.11",
"mocha": "^2.2.5",
"sinon": "^1.15.3"
}
"sinon": "^1.15.3",
"superstack": "0.0.4"
},
"generatorVersion": "0.2.20"
}
8 changes: 7 additions & 1 deletion paths.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
{
"source": {
"lib": "./es6/lib/**/*.js",
"spec": "./es6/spec/**/*.spec.js"
"spec": "./es6/spec/**/*.spec.js",
"specAssets": [
"./es6/spec/**/*.json"
],
"libAssets": [
"./es6/lib/**/*.json"
]
},

"build": {
Expand Down
9 changes: 9 additions & 0 deletions tasks/build-lib-assets.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import gulp from "gulp";
//import babel from "gulp-babel";

import paths from "../paths.json";

gulp.task("build-lib-assets", () => {
return gulp.src(paths.source.specAssets)
.pipe(gulp.dest(paths.build.directories.spec));
});
9 changes: 9 additions & 0 deletions tasks/build-spec-assets.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import gulp from "gulp";
//import babel from "gulp-babel";

import paths from "../paths.json";

gulp.task("build-spec-assets", () => {
return gulp.src(paths.source.specAssets)
.pipe(gulp.dest(paths.build.directories.spec));
});
2 changes: 1 addition & 1 deletion tasks/build.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import gulp from "gulp";

gulp.task("build", ["build-lib", "build-spec"]);
gulp.task("build", ["build-lib", "build-spec", "build-lib-assets", "build-spec-assets"]);
31 changes: 31 additions & 0 deletions tasks/suppress-errors.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import gulp from "gulp";
import gutil from "gulp-util";

// Watch tasks should depend on suppress-errors - it will force all stream pipes to print but not crash on error
gulp.task("suppress-errors", function(){
function monkeyPatchPipe(o){
while(!o.hasOwnProperty("pipe")){
o = Object.getPrototypeOf(o);
if(!o){
return;
}
}
var originalPipe = o.pipe;
var newPipe = function(){
var result = originalPipe.apply(this, arguments);
result.setMaxListeners(0);
if(!result.pipe["monkey patched for suppress-errors"]){
monkeyPatchPipe(result);
}

return result.on("error", function (err) {
gutil.log(gutil.colors.yellow(err));
gutil.beep();
this.emit("end");
});
};
newPipe["monkey patched for suppress-errors"] = true;
o.pipe = newPipe;
}
monkeyPatchPipe(gulp.src(""));
});
5 changes: 2 additions & 3 deletions tasks/test-browsers.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
var gulp = require("gulp");
var karma = require("karma").server;

gulp.task("test-browsers", function (done) {
gulp.task("test-browsers", ["build"], function (done) {
/**
* This ensures that the browser tests only run on the first job,
* instead of wastefully running the browser tests on every job.
Expand All @@ -19,7 +19,6 @@ gulp.task("test-browsers", function (done) {

function runKarma(done) {
karma.start({
configFile: __dirname + "/../.karma.conf.js",
singleRun: true
configFile: __dirname + "/../.karma.conf.js"
}, done);
}
2 changes: 1 addition & 1 deletion tasks/test-local.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import gulp from "gulp";
import mocha from "gulp-mocha";
import "superstack";
import istanbul from "gulp-istanbul";
import codeClimate from "./codeClimate";
import paths from "../paths.json";

import chai from "chai";
Expand Down
11 changes: 11 additions & 0 deletions tasks/test-watch.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import gulp from "gulp";
import paths from "../paths.json";

gulp.task("test-watch", ["suppress-errors"], () => {
gulp.watch([
paths.source.lib,
paths.source.spec,
paths.source.specAssets,
paths.source.libAssets
], ["test-local"]);
});

0 comments on commit c7f7627

Please sign in to comment.