diff --git a/test/.jshintrc b/.jshintrc similarity index 100% rename from test/.jshintrc rename to .jshintrc diff --git a/.travis.yml b/.travis.yml index 7396b16b..412d6518 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/gulpfile.js b/gulpfile.js new file mode 100644 index 00000000..195e9701 --- /dev/null +++ b/gulpfile.js @@ -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); + } + +})(); diff --git a/package.json b/package.json index 07eb7e4b..75656f67 100644 --- a/package.json +++ b/package.json @@ -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" diff --git a/test/test.js b/test/test.js index 882ea846..8df47984 100644 --- a/test/test.js +++ b/test/test.js @@ -49,37 +49,39 @@ '' + ''; - 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'); + } + }); + }; })(); diff --git a/test/test.sh b/test/test.sh deleted file mode 100755 index 8c26c5e2..00000000 --- a/test/test.sh +++ /dev/null @@ -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