feature(test) add gulp

This commit is contained in:
coderaiser 2014-03-31 10:05:01 -04:00
parent 010581248a
commit 50c1495eab
6 changed files with 88 additions and 43 deletions

View file

@ -9,6 +9,12 @@ matrix:
allow_failures:
- node_js: '0.11'
before_install:
- npm install -g gulp
script:
- gulp default
notifications:
#webhooks:
#http://requestb.in/12h5bl71

43
gulpfile.js Normal file
View file

@ -0,0 +1,43 @@
(function() {
'use strict';
var gulp = require('gulp'),
jshint = require('gulp-jshint'),
recess = require('gulp-recess'),
test = require('./test/test.js'),
LIB = './lib/',
LIB_CLIENT = LIB + 'client/',
Src = [
'./*.js',
LIB + '*/*.js',
LIB_CLIENT + 'storage/*.js',
'!' + LIB + 'diff/diff-match-patch.js',
'!' + LIB_CLIENT + 'jquery.js'
];
gulp.task('jshint', function() {
gulp.src(Src)
.pipe(jshint())
.pipe(jshint.reporter())
.on('error', onError);
});
gulp.task('recess', function () {
gulp.src('css/*.css')
.pipe(recess())
.on('error', onError);
});
gulp.task('test', function() {
test.check();
});
gulp.task('default', ['jshint', 'recess', 'test']);
function onError(params) {
console.log(params.message);
}
})();

View file

@ -12,7 +12,7 @@
"cloudcmd": "./bin/cloudcmd"
},
"scripts": {
"test": "sh ./test/test.sh",
"test": "gulp default",
"start": "cloudcmd.js"
},
"subdomain": "cloudcmd",
@ -25,6 +25,11 @@
"fs-extra": "0.8.x",
"marked": "~0.3.2"
},
"devDependencies": {
"gulp": "3.6.x",
"gulp-jshint": "1.5.x",
"gulp-recess": "0.3.x"
},
"license": "MIT",
"engines": {
"node": ">=0.4.x"

View file

@ -49,37 +49,39 @@
'</span>' +
'</div>';
files.read(Files, 'utf-8', function(errors, files) {
var i, n, template, pathTemplate, linkTemplate, expect, result;
if (errors)
Util.log(errors);
else {
Util.time('CloudFunc.buildFromJSON');
exports.check = function() {
files.read(Files, 'utf-8', function(errors, files) {
var i, n, template, pathTemplate, linkTemplate, expect, result;
template = files[TEMPLATEPATH];
pathTemplate = files[PATHTEMPLATE_PATH];
linkTemplate = files[LINK_TEMPLATE_PATH];
expect = files[EXPECT_PATH];
result = CloudFunc.buildFromJSON(JSON_FILES, template, pathTemplate, linkTemplate);
Expect += expect;
n = Expect.length;
for (i = 0; i < n; i++)
if (result[i] !== Expect[i]) {
Util.log('Error in char number: ' + i + '\n' +
'Expect: ' + Expect.substr(i) + '\n' +
'Result: ' + result.substr(i) );
break;
}
if (errors)
Util.log(errors);
else {
Util.time('CloudFunc.buildFromJSON');
if (i === n)
console.log('CloudFunc.buildFromJSON: OK');
Util.timeEnd('CloudFunc.buildFromJSON');
}
});
template = files[TEMPLATEPATH];
pathTemplate = files[PATHTEMPLATE_PATH];
linkTemplate = files[LINK_TEMPLATE_PATH];
expect = files[EXPECT_PATH];
result = CloudFunc.buildFromJSON(JSON_FILES, template, pathTemplate, linkTemplate);
Expect += expect;
n = Expect.length;
for (i = 0; i < n; i++)
if (result[i] !== Expect[i]) {
Util.log('Error in char number: ' + i + '\n' +
'Expect: ' + Expect.substr(i) + '\n' +
'Result: ' + result.substr(i) );
break;
}
if (i === n)
console.log('CloudFunc.buildFromJSON: OK');
Util.timeEnd('CloudFunc.buildFromJSON');
}
});
};
})();

View file

@ -1,11 +0,0 @@
#!/bin/sh
npm i recess jshint
echo "jshint lib/*.js lib/client/*.js lib/client/storage/*.js lib/server/*.js"
node_modules/jshint/bin/jshint --config test/.jshintrc lib/*.js `ls lib/client/*.js| grep -v jquery` lib/client/storage/*.js lib/server/*.js
echo "jshint package.json json/*.json"
node_modules/jshint/bin/jshint --config test/.jshintrc package.json json/*.json
#linting css files
echo "recess css/*.css"
./node_modules/recess/bin/recess css/*.css
node test/test.js
node cloudcmd.js test