From bb8b86e4c5e601e9fef04afa227f4353fe2458fb Mon Sep 17 00:00:00 2001 From: "Dr. Kibitz" Date: Sun, 26 Jan 2014 12:39:15 -0800 Subject: [PATCH] Use Gulp instead of Grunt --- .travis.yml | 8 +++--- Gruntfile.js | 71 ---------------------------------------------------- gulpfile.js | 59 +++++++++++++++++++++++++++++++++++++++++++ index.js | 4 +-- package.json | 14 ++++++----- 5 files changed, 73 insertions(+), 83 deletions(-) delete mode 100644 Gruntfile.js create mode 100644 gulpfile.js diff --git a/.travis.yml b/.travis.yml index a242bd7..5a00f0f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,16 +6,16 @@ env: global: - secure: CetX10W3SCeTfvyM4c4GutdprDsRWdBgwc1Iw0eFW63Uphep1JYNhqy5oLRkGX7keBCJGmERr32Z5R0N+FWAyzP80qt1Cn4aoxaKvYsFbmW8Mmo5DaPKA0yH4NnnuQLd0kCObgh1ptaG/PMc4HxvgU1T5zkUdd3lwxUZcqd6jPA= install: -- npm install grunt-cli istanbul coveralls +- npm install istanbul coveralls - npm install cache: directories: - node_modules script: -- ./node_modules/.bin/grunt jshint -- ./node_modules/.bin/istanbul cover ./node_modules/.bin/grunt mochaTest:source +- ./node_modules/.bin/gulp jshint +- ./node_modules/.bin/istanbul cover ./node_modules/.bin/gulp test-source - cat ./build/coverage/lcov.info | ./node_modules/.bin/coveralls -- ./node_modules/.bin/grunt uglify mochaTest:dist +- ./node_modules/.bin/gulp test-dist deploy: api_key: secure: iX4IdMDpceD95iXwmboCh94uDam3R3LtYga9zMqtZYcFq+0pCpBxr2AIF2xLltK1i2iOh01Du0Jmkjc1M/j1S1/ZlzqtLXHjrMPAXjjblzkAAZFVyrwfczAh3e5apo6O1ytEUTydyphhvBHMJKv4BkVMd747PZYQNKrhDgy1i6Y= diff --git a/Gruntfile.js b/Gruntfile.js deleted file mode 100644 index 5e22298..0000000 --- a/Gruntfile.js +++ /dev/null @@ -1,71 +0,0 @@ -module.exports = function(grunt) { - 'use strict'; - - var banner = [ - '/**', - ' * <%= pkg.name %> <%= pkg.version %>', - ' * <%= pkg.homepage %>', - ' * Copyright (c) 2013 Dr. Kibitz, http://drkibitz.com', - ' * <%= pkg.description %>', - ' * built: ' + new Date(), - ' */', - '' - ].join('\n'); - - grunt.initConfig({ - pkg: require('./package.json'), - docstrap: 'node_modules/grunt-jsdoc/node_modules/ink-docstrap/template', - jshint: { - test: ['Gruntfile.js', 'src/**/*.js', 'test/**/*.js'], - options: { - jshintrc: '.jshintrc' - } - }, - jsdoc: { - docs: { - src: ['package.json', 'README.md', 'src/**/*.js'], - dest: 'build/docs' - }, - options: { - template: '<%= docstrap %>', - configure: 'jsdoc.conf.json' - } - }, - mochaTest: { - source: { - src: ['test/unit/**/*.js'], - options: { - require: ['test/source'] - } - }, - dist: { - src: ['test/unit/**/*.js'], - options: { - require: ['test/dist'] - } - }, - options: { - reporter: 'spec' - } - }, - uglify: { - dist: { - files: { - 'index.js': ['src/index.js'] - } - }, - options: { - banner: banner, - wrap: true - } - } - }); - - grunt.loadNpmTasks('grunt-contrib-jshint'); - grunt.loadNpmTasks('grunt-contrib-uglify'); - grunt.loadNpmTasks('grunt-jsdoc'); - grunt.loadNpmTasks('grunt-mocha-test'); - - grunt.registerTask('test', ['jshint', 'uglify', 'mochaTest:dist']); - grunt.registerTask('default', ['test', 'jsdoc']); -}; diff --git a/gulpfile.js b/gulpfile.js new file mode 100644 index 0000000..2abe397 --- /dev/null +++ b/gulpfile.js @@ -0,0 +1,59 @@ +/*jshint node:true*/ +'use strict'; + +var gulp = require('gulp'), + jshint = require('gulp-jshint'), + map = require('map-stream'), + mocha = require('gulp-mocha'), + uglify = require('gulp-uglify'), + pkg = require('./package.json'), + banner = [ + '/**', + ' * ' + pkg.name + ' ' + pkg.version, + ' * ' + pkg.homepage, + ' * Copyright (c) 2013 Dr. Kibitz, http://drkibitz.com', + ' * ' + pkg.description, + ' * built: ' + new Date(), + ' */', + '' + ].join('\n'); + +gulp.task('jshint', function () { + return gulp.src(['gulpfile.js', 'src/**/*.js', 'test/**/*.js']) + .pipe(jshint('.jshintrc')) + .pipe(jshint.reporter('default')); +}); + +gulp.task('uglify', function () { + return gulp.src('src/index.js') + .pipe(map(function (file, cb) { + file.contents = Buffer.concat([ + new Buffer('(function(module,exports){'), + file.contents, + new Buffer('}(module,exports));') + ]); + cb(null, file); + })) + .pipe(uglify({wrap: 'nodes'})) + .pipe(map(function (file, cb) { + file.contents = Buffer.concat([new Buffer(banner), file.contents]); + cb(null, file); + })) + .pipe(gulp.dest('./')); +}); + +function testTask(requireModule) { + return function () { + return gulp.src('test/unit/**/*.js', {read: false}) + .pipe(mocha({ + reporter: 'spec', + globals: { + nodes: require(requireModule) + } + })); + }; +} +gulp.task('test-source', testTask('./test/source')); +gulp.task('test-dist', ['uglify'], testTask('./test/dist')); + +gulp.task('default', ['jshint', 'test-dist']); diff --git a/index.js b/index.js index 4215d8f..dcf6d56 100644 --- a/index.js +++ b/index.js @@ -3,6 +3,6 @@ * http://drkibitz.github.io/qi-nodes/ * Copyright (c) 2013 Dr. Kibitz, http://drkibitz.com * Base implementation for composite patterns in JavaScript. - * built: Sun Jan 12 2014 00:07:51 GMT-0800 (PST) + * built: Sun Jan 26 2014 12:55:14 GMT-0800 (PST) */ -!function(a,b){"use strict";function c(a){this.message=a||"A NodeObject was inserted somewhere it doesn't belong."}function d(a){a.childCount=0,a.firstChild=a.lastChild=a.nextSibling=a.parent=a.previousSibling=a.root=null}function e(a){var b=a.parent,c=a.nextSibling,d=a.previousSibling;return b.childCount--,c?c.previousSibling=d:b.lastChild=d,d?d.nextSibling=c:b.firstChild=c,a.parent=a.nextSibling=a.previousSibling=null,a}function f(a){var b=a.root,c=a.parent?a.parent.root:null;b&&a.onRemoved&&a.onRemoved(b),c&&a.onInserted&&a.onInserted(c),a.root=c}function g(a){d(this),a&&this.appendTo(a)}b["true"]=a,c.prototype=new Error,c.prototype.name="HierarchyRequestError";var h=g.prototype;h.append=function(a,b){return this.appendTo(b||this,a)},h.appendTo=function(a,b){var d,g=a.lastChild;if(b=b||this,b==a)throw new c;return b!=g&&(b.parent&&e(b),b.parent=a,d=0|a.childCount,a.childCount=d+1,g&&(b.previousSibling=g,g.nextSibling=b),a.lastChild=b,a.firstChild||(a.firstChild=b),b.root!=a.root&&this.each(f,b)),b},h.create=function(a){return new g(a)},h.createRoot=function(){var a=new g;return a.root=a,a},h.destroy=function(a,b){return b=b||this,a?this.eachReverse(d,b):(b.root=null,b.parent&&e(b),b.firstChild&&this.empty(a,b)),b},h.each=function i(a,b,c){var d,e;for(b=b||this,c=0|c,d=b.firstChild,a(b,c);d;)e=d.nextSibling,i(a,d,c+1),d=e;return b},h.eachParent=function j(a,b,c){return b=b||this,c=0|c,b.parent&&j(a,b.parent,c+1),a(b,c),b},h.eachReverse=function k(a,b,c){var d,e;for(b=b||this,c=0|c,d=b.lastChild;d;)e=d.previousSibling,k(a,d,c+1),d=e;return a(b,c),b},h.empty=function(a,b){var c,e;for(b=b||this,c=b.firstChild,c&&a&&(b.childCount=0,b.firstChild=b.lastChild=null);c;)e=c.nextSibling,a?this.eachReverse(d,c):this.remove(c),c=e;return b},h.insertAfter=function(a,b){var d,g,h=a.nextSibling;if(b=b||this,b!=a&&b!=h){if(d=a.parent,!d||b==d)throw new c;b.parent&&e(b),b.previousSibling=a,b.nextSibling=h,b.parent=d,h?h.previousSibling=b:d.lastChild=b,a.nextSibling=b,g=0|d.childCount,d.childCount=g+1,b.root!=d.root&&this.each(f,b)}return b},h.insertBefore=function(a,b){var d,g,h=a.previousSibling;if(b=b||this,b!=a&&b!=h){if(d=a.parent,!d||b==d)throw new c;b.parent&&e(b),b.previousSibling=h,b.nextSibling=a,b.parent=d,h?h.nextSibling=b:d.firstChild=b,a.previousSibling=b,g=0|d.childCount,d.childCount=g+1,b.root!=d.root&&this.each(f,b)}return b},h.prepend=function(a,b){return this.prependTo(b||this,a)},h.prependTo=function(a,b){var d,g=a.firstChild;if(b=b||this,b==a)throw new c;return b!=g&&(b.parent&&e(b),b.parent=a,d=0|a.childCount,a.childCount=d+1,g&&(b.nextSibling=g,g.previousSibling=b),a.firstChild=b,a.lastChild||(a.lastChild=b),b.root!=a.root&&this.each(f,b)),b},h.remove=function(a){return a=e(a||this),a.root?this.each(f,a):a},h.swap=function(a,b){var c,d,e,g,h,i=a.nextSibling;return b=b||this,a!=b&&(c=a.parent,d=a.previousSibling,e=b.nextSibling,g=b.parent,h=b.previousSibling,a.nextSibling=e,a.parent=g,a.previousSibling=h,e?e.previousSibling=a:g&&(g.lastChild=a),h?h.nextSibling=a:g&&(g.firstChild=a),b.nextSibling=i,b.parent=c,b.previousSibling=d,i?i.previousSibling=b:c&&(c.lastChild=b),d?d.nextSibling=b:c&&(c.firstChild=b),(a.root&&!g||a.root!=g.root)&&this.each(f,a),(b.root&&!c||b.root!=c.root)&&this.each(f,b)),a},a=module.exports=h.createRoot(),a.HierarchyRequestError=c,a.NodeObject=g}({},function(){return this}()); \ No newline at end of file +!function(i,t){"use strict";function n(i){this.message=i||"A NodeObject was inserted somewhere it doesn't belong."}function e(i){i.childCount=0,i.firstChild=i.lastChild=i.nextSibling=i.parent=i.previousSibling=i.root=null}function r(i){var t=i.parent,n=i.nextSibling,e=i.previousSibling;return t.childCount--,n?n.previousSibling=e:t.lastChild=e,e?e.nextSibling=n:t.firstChild=n,i.parent=i.nextSibling=i.previousSibling=null,i}function o(i){var t=i.root,n=i.parent?i.parent.root:null;t&&i.onRemoved&&i.onRemoved(t),n&&i.onInserted&&i.onInserted(n),i.root=n}function l(i){e(this),i&&this.appendTo(i)}n.prototype=new Error,n.prototype.name="HierarchyRequestError";var s=l.prototype;s.append=function(i,t){return this.appendTo(t||this,i)},s.appendTo=function(i,t){var e,l=i.lastChild;if(t=t||this,t==i)throw new n;return t!=l&&(t.parent&&r(t),t.parent=i,e=0|i.childCount,i.childCount=e+1,l&&(t.previousSibling=l,l.nextSibling=t),i.lastChild=t,i.firstChild||(i.firstChild=t),t.root!=i.root&&this.each(o,t)),t},s.create=function(i){return new l(i)},s.createRoot=function(){var i=new l;return i.root=i,i},s.destroy=function(i,t){return t=t||this,i?this.eachReverse(e,t):(t.root=null,t.parent&&r(t),t.firstChild&&this.empty(i,t)),t},s.each=function h(i,t,n){var e,r;for(t=t||this,n=0|n,e=t.firstChild,i(t,n);e;)r=e.nextSibling,h(i,e,n+1),e=r;return t},s.eachParent=function u(i,t,n){return t=t||this,n=0|n,t.parent&&u(i,t.parent,n+1),i(t,n),t},s.eachReverse=function a(i,t,n){var e,r;for(t=t||this,n=0|n,e=t.lastChild;e;)r=e.previousSibling,a(i,e,n+1),e=r;return i(t,n),t},s.empty=function(i,t){var n,r;for(t=t||this,n=t.firstChild,n&&i&&(t.childCount=0,t.firstChild=t.lastChild=null);n;)r=n.nextSibling,i?this.eachReverse(e,n):this.remove(n),n=r;return t},s.insertAfter=function(i,t){var e,l,s=i.nextSibling;if(t=t||this,t!=i&&t!=s){if(e=i.parent,!e||t==e)throw new n;t.parent&&r(t),t.previousSibling=i,t.nextSibling=s,t.parent=e,s?s.previousSibling=t:e.lastChild=t,i.nextSibling=t,l=0|e.childCount,e.childCount=l+1,t.root!=e.root&&this.each(o,t)}return t},s.insertBefore=function(i,t){var e,l,s=i.previousSibling;if(t=t||this,t!=i&&t!=s){if(e=i.parent,!e||t==e)throw new n;t.parent&&r(t),t.previousSibling=s,t.nextSibling=i,t.parent=e,s?s.nextSibling=t:e.firstChild=t,i.previousSibling=t,l=0|e.childCount,e.childCount=l+1,t.root!=e.root&&this.each(o,t)}return t},s.prepend=function(i,t){return this.prependTo(t||this,i)},s.prependTo=function(i,t){var e,l=i.firstChild;if(t=t||this,t==i)throw new n;return t!=l&&(t.parent&&r(t),t.parent=i,e=0|i.childCount,i.childCount=e+1,l&&(t.nextSibling=l,l.previousSibling=t),i.firstChild=t,i.lastChild||(i.lastChild=t),t.root!=i.root&&this.each(o,t)),t},s.remove=function(i){return i=r(i||this),i.root?this.each(o,i):i},s.swap=function(i,t){var n,e,r,l,s,h=i.nextSibling;return t=t||this,i!=t&&(n=i.parent,e=i.previousSibling,r=t.nextSibling,l=t.parent,s=t.previousSibling,i.nextSibling=r,i.parent=l,i.previousSibling=s,r?r.previousSibling=i:l&&(l.lastChild=i),s?s.nextSibling=i:l&&(l.firstChild=i),t.nextSibling=h,t.parent=n,t.previousSibling=e,h?h.previousSibling=t:n&&(n.lastChild=t),e?e.nextSibling=t:n&&(n.firstChild=t),(i.root&&!l||i.root!=l.root)&&this.each(o,i),(t.root&&!n||t.root!=n.root)&&this.each(o,t)),i},t=i.exports=s.createRoot(),t.HierarchyRequestError=n,t.NodeObject=l}(module,exports); \ No newline at end of file diff --git a/package.json b/package.json index 215b60b..c4efc13 100644 --- a/package.json +++ b/package.json @@ -2,11 +2,13 @@ "author": "Dr. Kibitz ", "bugs": "https://github.com/drkibitz/qi-nodes/issues", "devDependencies": { - "grunt": "0.4.x", - "grunt-contrib-jshint": "0.8.x", - "grunt-contrib-uglify": "0.2.x", - "grunt-jsdoc": "0.5.x", - "grunt-mocha-test": "0.8.x" + "gulp": "~3.5.0", + "gulp-jshint": "~1.3.4", + "gulp-mocha": "~0.4.1", + "gulp-uglify": "~0.2.0", + "gulp-util": "*", + "map-stream": "~0.1.0", + "mocha": "*" }, "description": "Base implementation for composite patterns in JavaScript.", "files": [ @@ -26,7 +28,7 @@ "name": "qi-nodes", "repository": "https://github.com/drkibitz/qi-nodes", "scripts": { - "test": "grunt test" + "test": "./node_modules/.bin/gulp test" }, "version": "0.0.3" }