Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added gulp automation and jscs linting.
- Loading branch information
Paolo Scanferla
committed
May 1, 2015
1 parent
7f4ed60
commit c371d15
Showing
19 changed files
with
219 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
coverage/ | ||
node_modules/ | ||
node_modules/* | ||
builds/ | ||
.publish/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"preset": "crockford", | ||
"requireMultipleVarDecl": null, | ||
"disallowSpacesInNamedFunctionExpression": null, | ||
"disallowDanglingUnderscores": null | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,15 @@ | ||
language: node_js | ||
|
||
node_js: | ||
- "0.12" | ||
- "iojs" | ||
- iojs | ||
|
||
services: | ||
- mongodb | ||
|
||
env: | ||
- NODE_PATH=./src/ | ||
|
||
script: | ||
- ./node_modules/.bin/istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly -- -R spec test/unit/**/*.js | ||
- cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js | ||
- ./node_modules/.bin/mocha test/integration/*.js | ||
- ./node_modules/.bin/jscs src/ | ||
- ./node_modules/.bin/istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly -- -R spec test/unit/**/*.js test/integration/*.js | ||
- cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
var bs = require("browser-sync"); | ||
var sh = require("child_process").execSync; | ||
var fs = require("fs"); | ||
var gulp = require("gulp"); | ||
var ghPages = require("gulp-gh-pages"); | ||
var mocha = require("gulp-spawn-mocha"); | ||
var mkdirp = require("mkdirp"); | ||
|
||
/* | ||
* Task to run unit tests | ||
*/ | ||
gulp.task("test", function () { | ||
var stream = gulp.src(["./test/unit/**/*.js", "./test/integration/**/*.js"]) | ||
.pipe(mocha({ | ||
reporter: "mochawesome", | ||
istanbul: { | ||
dir: "./builds/coverage/" | ||
}, | ||
env: { | ||
NODE_PATH: "./src/", | ||
MOCHAWESOME_REPORTDIR: "./builds/tests/", | ||
MOCHAWESOME_REPORTNAME: "index" | ||
} | ||
})) | ||
.on("error", function (ignore) { | ||
/* | ||
* Failing tests are counted as errors and therefore break the | ||
* stream. Catch and ignore them. Also, terminate the stream, | ||
* otherwise we might have problems with gulp.watch | ||
*/ | ||
bs.reload(); | ||
stream.end(); | ||
}) | ||
.pipe(bs.reload({stream: true})); | ||
return stream; | ||
}); | ||
|
||
/* | ||
* Task to lint source code using jscs | ||
*/ | ||
gulp.task("jscs", function () { | ||
/* | ||
* Generate the report | ||
*/ | ||
mkdirp.sync("./builds/jscs/"); | ||
try { | ||
sh("../../node_modules/.bin/jscs ../../src/ --reporter ../../node_modules/jscs-html-reporter/jscs-html-reporter.js", { | ||
cwd: "./builds/jscs/" | ||
}); | ||
} catch (ignore) { | ||
// Prevent exiting the process on jscs errors | ||
} | ||
/* | ||
* Copy resources needed by the html reporter over to ./builds/jscs/ | ||
*/ | ||
sh("cp ./node_modules/jscs-html-reporter/jscs-html-reporter.css ./builds/jscs/"); | ||
sh("cp ./node_modules/jscs-html-reporter/toggle.js ./builds/jscs/"); | ||
/* | ||
* Replace resources paths, since we copy those resources over to | ||
* ./builds/jscs/ | ||
*/ | ||
var htmlReport = fs.readFileSync("./builds/jscs/jscs-html-report.html", "utf8"); | ||
htmlReport = htmlReport.replace( | ||
new RegExp("../../node_modules/jscs-html-reporter/", "g"), | ||
"" | ||
); | ||
fs.writeFileSync("./builds/jscs/index.html", htmlReport, "utf8"); | ||
sh("rm ./builds/jscs/jscs-html-report.html"); | ||
/* | ||
* BrowserSync reload | ||
*/ | ||
bs.reload(); | ||
}); | ||
|
||
/* | ||
* Setup the development server | ||
*/ | ||
gulp.task("server", function() { | ||
bs({ | ||
server: { | ||
baseDir: "./builds/", | ||
directory: true | ||
}, | ||
port: 8080, | ||
ghostMode: false, | ||
injectChanges: false, | ||
notify: false | ||
}); | ||
}); | ||
|
||
/* | ||
* Task to rerun tests and linting on file change | ||
*/ | ||
gulp.task("dev", ["server"], function () { | ||
return gulp.watch([ | ||
"src/**/*.js", | ||
"test/**/*.js" | ||
], ["jscs", "test"]); | ||
}); | ||
|
||
/* | ||
* Task to deploy to github pages | ||
*/ | ||
gulp.task("gh-pages", ["test", "jscs"], function() { | ||
return gulp.src("./builds/**/*").pipe(ghPages()); | ||
}); | ||
|
||
/* | ||
* Default task | ||
*/ | ||
gulp.task("default", [ | ||
"jscs", | ||
"test", | ||
"dev" | ||
]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.