mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-18 00:47:01 +00:00
feature(test) add gulp
This commit is contained in:
parent
010581248a
commit
50c1495eab
6 changed files with 88 additions and 43 deletions
|
|
@ -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
43
gulpfile.js
Normal 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);
|
||||
}
|
||||
|
||||
})();
|
||||
|
|
@ -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"
|
||||
|
|
|
|||
64
test/test.js
64
test/test.js
|
|
@ -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');
|
||||
}
|
||||
});
|
||||
};
|
||||
})();
|
||||
|
|
|
|||
11
test/test.sh
11
test/test.sh
|
|
@ -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
|
||||
Loading…
Add table
Add a link
Reference in a new issue