Skip to content
This repository was archived by the owner on Jan 11, 2022. It is now read-only.

Commit 3e9ebbe

Browse files
committed
build with gulp
1 parent f587d91 commit 3e9ebbe

3 files changed

Lines changed: 105 additions & 5 deletions

File tree

gulpfile.js

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
/*
2+
* Copyright (C) 2013 Conjur Inc
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a copy of
5+
* this software and associated documentation files (the "Software"), to deal in
6+
* the Software without restriction, including without limitation the rights to
7+
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
8+
* the Software, and to permit persons to whom the Software is furnished to do so,
9+
* subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included in all
12+
* copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
16+
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
17+
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
18+
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20+
*/
21+
22+
"use strict";
23+
24+
var gulp = require('gulp'),
25+
jslint = require('gulp-jslint'),
26+
mocha = require('gulp-mocha'),
27+
silenceLogger = require('./testconfig');
28+
29+
require('coffee-script/register');
30+
31+
var sources = ['lib/**/*.js'];
32+
var tests = ['test/**/*_test.coffee'];
33+
34+
35+
function chooseMochaReporter(){
36+
// if TEST_REPORTER is set, use that
37+
if(process.env.TEST_REPORTER){
38+
return process.env.TEST_REPORTER;
39+
}
40+
41+
if(process.stdout.isTTY){
42+
// use the always popular nyancat reporter if we're
43+
// in someones terminal
44+
return 'nyan';
45+
}
46+
// spec is a useful format, and looks good whether or not you're
47+
// in a terminal.
48+
return 'spec';
49+
}
50+
51+
52+
53+
var mochaOpts = {
54+
reporter: chooseMochaReporter()
55+
};
56+
57+
var jslintOpts = {
58+
// assume node.js
59+
node: true,
60+
// don't worry about sloppy whitespace
61+
white: true,
62+
// this one makes regexps of any kind impossible to use,
63+
// for example it calls "." insecure, as well as "^", even
64+
// when using it in a character class like "[^foo]".
65+
regexp: true,
66+
// This one makes maintaining backwards compatibility more or less impossible.
67+
// See the xyzUrl functions in lib/config.js
68+
unparam: true,
69+
// don't print successes
70+
errorsOnly: true
71+
};
72+
73+
74+
gulp.task('lint', function(){
75+
return gulp.src(sources)
76+
.pipe(jslint(jslintOpts));
77+
});
78+
79+
gulp.task('test', function(){
80+
silenceLogger();
81+
return gulp.src(tests, {read: false})
82+
.pipe(mocha(mochaOpts));
83+
});
84+
85+
gulp.task('default', ['lint', 'test']);
86+
87+
gulp.task('watch', function(){
88+
gulp.watch(['lib/**/*.js', 'test/**/*.coffee', 'gulpfile.js'], ['default']);
89+
});

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818
"doctor": "latest",
1919
"mocha": "latest",
2020
"coffee-script": "latest",
21-
"browserify": "~3.14.1"
21+
"browserify": "~3.14.1",
22+
"gulp": "~3.8.10",
23+
"gulp-jslint": "~0.2.2",
24+
"gulp-mocha": "~2.0.0",
25+
"xunit-file": "0.0.6"
2226
}
2327
}

testconfig.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
1-
var winston = require('winston')
2-
;
1+
"use strict";
32

4-
winston.remove(winston.transports.Console);
5-
winston.add(winston.transports.File, {filename: 'test.log', level: 'debug'})
3+
var winston = require('winston');
4+
5+
module.exports = function(){
6+
try {
7+
winston.remove(winston.transports.Console);
8+
}catch(e){
9+
return;
10+
}
11+
winston.add(winston.transports.File, {filename: 'test.log', level: 'debug'});
12+
};

0 commit comments

Comments
 (0)