From a191cb4a07a271dd735b5de5438724dc5557e86b Mon Sep 17 00:00:00 2001 From: Alexander Early Date: Thu, 21 Jan 2016 14:39:04 -0800 Subject: clean up makefile, add smoke test to build process --- .gitignore | 1 + Makefile | 37 ++++++++++++++++++++++++++----------- build/async.min.js | 2 ++ support/build.test.js | 28 ++++++++++++++++++++++++++++ 4 files changed, 57 insertions(+), 11 deletions(-) create mode 100644 build/async.min.js diff --git a/.gitignore b/.gitignore index 8feeb01..a8bd61b 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ coverage *.log .DS_Store npm-debug.log +tmp diff --git a/Makefile b/Makefile index 73ea64d..8d98a92 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,7 @@ +# This makefile is meant to be run on OSX/Linux. Make sure any artifacts +# created here are checked in so people on all platforms can run npm scripts. +# This build should be run once per release. + export PATH := ./node_modules/.bin/:$(PATH):./bin/ PACKAGE = asyncjs @@ -14,6 +18,7 @@ JS_SRC = $(shell find lib/ -type f -name '*.js') package.json LINT_FILES = lib/ test/ mocha_test/ $(shell find perf/ -maxdepth 2 -type f) support/ gulpfile.js karma.conf.js UMD_BUNDLE = $(BUILDDIR)/async.js +UMD_BUNDLE_MIN = $(BUILDDIR)/async.min.js CJS_BUNDLE = $(BUILDDIR)/index.js all: lint test clean build @@ -21,9 +26,6 @@ all: lint test clean build test: npm test -test-build: build - mocha support/build.test.js - clean: rm -rf $(BUILDDIR) rm -rf $(DIST) @@ -32,7 +34,7 @@ lint: jshint $(LINT_FILES) jscs $(LINT_FILES) - +# Compile the ES6 modules to singular bundles, and individual bundles build-bundle: build-modules $(UMD_BUNDLE) $(CJS_BUNDLE) build-modules: @@ -44,16 +46,29 @@ $(UMD_BUNDLE): $(JS_SRC) $(CJS_BUNDLE): $(JS_SRC) $(BABEL_NODE) $(SCRIPTS)/build/aggregate-cjs.js -.PHONY: build-modules build-bundle +# Create the minified UMD versions and copy them to dist/ for bower +build-dist: $(DIST) $(DIST)/async.js $(DIST)/async.min.js $(UMD_BUNDLE_MIN) + +$(DIST): + mkdir -p $(DIST)/ -build-dist: - mkdir -p $(DIST) - cp $(BUILDDIR)/async.js $(DIST)/async.js - $(UGLIFY) $(DIST)/async.js -mc \ +$(UMD_BUNDLE_MIN): $(UMD_BUNDLE) + $(UGLIFY) $< --mangle --compress \ --source-map $(DIST)/async.min.map \ - -o $(DIST)/async.min.js + -o $@ + +$(DIST)/async.js: $(UMD_BUNDLE) + cp $< $@ + +$(DIST)/async.min.js: $(UMD_BUNDLE_MIN) + cp $< $@ + +test-build: + mocha support/build.test.js + +.PHONY: build-modules build-bundle build-dist test-build -build: clean build-bundle build-dist +build: clean build-bundle build-dist test-build .PHONY: test lint build all clean diff --git a/build/async.min.js b/build/async.min.js new file mode 100644 index 0000000..5191d1f --- /dev/null +++ b/build/async.min.js @@ -0,0 +1,2 @@ +!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(n.async={})}(this,function(n){"use strict";function t(n){var t=typeof n;return!!n&&("object"==t||"function"==t)}function r(n,t,r){var e=r?r.length:0;switch(e){case 0:return n.call(t);case 1:return n.call(t,r[0]);case 2:return n.call(t,r[0],r[1]);case 3:return n.call(t,r[0],r[1],r[2])}return n.apply(t,r)}function e(n){var r=t(n)?Hn.call(n):"";return r==Un||r==Cn}function u(n){if(t(n)){var r=e(n.valueOf)?n.valueOf():n;n=t(r)?r+"":r}if("string"!=typeof n)return 0===n?n:+n;n=n.replace(Qn,"");var u=Wn.test(n);return u||Gn.test(n)?Jn(n.slice(2),u?2:8):Rn.test(n)?Nn:+n}function i(n){if(!n)return 0===n?n:0;if(n=u(n),n===Kn||n===-Kn){var t=0>n?-1:1;return t*Vn}var r=n%1;return n===n?r?n-r:n:0}function o(n,t){if("function"!=typeof n)throw new TypeError(Xn);return t=Yn(void 0===t?n.length-1:i(t),0),function(){for(var e=arguments,u=-1,i=Yn(e.length-t,0),o=Array(i);++u0&&(r=t.apply(this,arguments)),1>=n&&(t=void 0),r}}function p(n){return s(2,n)}function h(){}function y(n){return"number"==typeof n&&n>-1&&n%1==0&&nt>=n}function m(n){return null!=n&&!("function"==typeof n&&e(n))&&y(_n(n))}function v(n,t){return rt.call(n,t)||"object"==typeof n&&t in n&&null===et(n)}function d(n){return ut(Object(n))}function g(n,t){for(var r=-1,e=Array(n);++r-1&&n%1==0&&t>n}function L(n){var t=n&&n.constructor,r="function"==typeof t&&t.prototype||vt;return n===r}function O(n){var t=L(n);if(!t&&!m(n))return d(n);var r=S(n),e=!!r,u=r||[],i=u.length;for(var o in n)!v(n,o)||e&&("length"==o||j(o,i))||t&&"constructor"==o||u.push(o);return u}function x(n){var t,r=-1;if(m(n))return t=n.length,function(){return r++,t>r?r:null};var e=O(n);return t=e.length,function(){return r++,t>r?e[r]:null}}function A(n){return function(){if(null===n)throw new Error("Callback was already called.");n.apply(this,arguments),n=null}}function I(n,t,r){function e(){var o=!0;return null===i?r(null):(t(n[i],i,A(function(n){if(n)r(n);else{if(i=u(),null===i)return r(null);o?gt(e):e()}})),void(o=!1))}r=p(r||h),n=n||[];var u=x(n),i=u();e()}function T(n){return function(t,r,e){return n(I,t,r,e)}}function z(n){return function(t,r,e){e=p(e||h),t=t||[];var u=x(t);if(0>=n)return e(null);var i=!1,o=0,c=!1;!function a(){if(i&&0>=o)return e(null);for(;n>o&&!c;){var f=u();if(null===f)return i=!0,void(0>=o&&e(null));o+=1,r(t[f],f,A(function(n){o-=1,n?(e(n),c=!0):a()}))}}()}}function M(n){return function(t,r,e,u){return n(z(r),t,e,u)}}function $(n,t,r){function e(n){o--,n?r(n):null===u&&0>=o&&r(null)}r=p(r||h),n=n||[];for(var u,i=x(n),o=0;null!=(u=i());)o+=1,t(n[u],u,A(e));0===o&&r(null)}function q(n){return function(t,r,e){return n($,t,r,e)}}function B(n,t,r,e){I(n,function(n,e,u){r(t,n,function(n,r){t=r,u(n)})},function(n){e(n,t)})}function F(n,t,r,e){var u=Et.call(n).reverse();B(u,t,r,e)}function P(n,t,r,e){z(t)(n,r,e)}function U(n){return function(t,r,e){return n(t,e)}}function C(n,t,r,e){return z(t)(n,U(r),e)}function D(n,t,r){return I(n,U(t),r)}function H(n,t,r){return $(n,U(t),r)}function N(n){return n}function Q(n,t,r){return function(e,u,i,o){function c(){o&&o(r(!1,void 0))}function a(n,e,u){return o?void i(n,function(e){o&&t(e)&&(o(r(!0,n)),o=i=!1),u()}):u()}arguments.length>3?n(e,u,a,c):(o=i,i=u,n(e,a,c))}}function R(n){return!n}function W(n,t,r){if(r=r||h,!n())return r(null);var e=o(function(u,i){return u?r(u):n.apply(this,i)?t(e):void r.apply(null,[null].concat(i))});t(e)}function G(n){return o(function(t){var r=t.pop(),e=!0;t.push(function(){var n=arguments;e?gt(function(){r.apply(null,n)}):r.apply(null,n)}),n.apply(this,t),e=!1})}function J(n){function t(r){function e(){return n.length&&n[r].apply(null,arguments),e.next()}return e.next=function(){return rr?-1:r>e?1:0}It(n,function(n,r){t(n,function(t,e){return t?r(t):void r(null,{value:n,criteria:e})})},function(n,t){return n?r(n):void r(null,a(t.sort(e),f("value")))})}function un(n,t,r){r=r||h;var e=m(t)?[]:{};n(t,function(n,t,r){n(o(function(n,u){u.length<=1&&(u=u[0]),e[t]=u,r(n)}))},function(n){r(n,e)})}function on(n,t){return un(I,n,t)}function cn(){var n=arguments;return o(function(t){var r=this,e=t[t.length-1];"function"==typeof e?t.pop():e=h,B(n,t,function(n,t,e){t.apply(r,n.concat([o(function(n,t){e(n,t)})]))},function(n,t){e.apply(r,[n].concat(t))})})}function an(n,t,r){function e(n,t){if("number"==typeof t)n.times=parseInt(t,10)||i;else{if("object"!=typeof t)throw new Error("Unsupported argument type for 'times': "+typeof t);n.times=parseInt(t.times,10)||i,n.interval=parseInt(t.interval,10)||o}}function u(n,t){function r(n,r){return function(e){n(function(n,t){e(!n||r,{err:n,result:t})},t)}}function e(n){return function(t){setTimeout(function(){t(null)},n)}}for(;a.times;){var u=!(a.times-=1);c.push(r(a.task,u)),!u&&a.interval>0&&c.push(e(a.interval))}on(c,function(t,r){r=r[r.length-1],(n||a.callback)(r.err,r.result)})}var i=5,o=0,c=[],a={times:i,interval:o},f=arguments.length;if(1>f||f>3)throw new Error("Invalid arguments - must be either (task), (task, callback), (times, task) or (times, task, callback)");return 2>=f&&"function"==typeof n&&(r=t,t=n),"function"!=typeof n&&e(a,n),a.callback=r,a.task=t,a.callback?u():u}function fn(n,t,r,e){l(n,t,function(n,t){r(n,function(n){t(!n)})},e)}function ln(n,t){for(var r=-1,e=n.length;++r=t;t++)gt(c.process)}}};return c}function pn(n,t){return sn(function(t,r){n(t[0],r)},t,1)}function hn(n,t){function r(n,t){return n.priority-t.priority}function e(n,t,r){for(var e=-1,u=n.length-1;u>e;){var i=e+(u-e+1>>>1);r(t,n[i])>=0?e=i:u=i-1}return e}function u(n,t,u,i){if(null!=i&&"function"!=typeof i)throw new Error("task callback must be a function");return n.started=!0,lt(t)||(t=[t]),0===t.length?gt(function(){n.drain()}):void ln(t,function(t){var o={data:t,priority:u,callback:"function"==typeof i?i:h};n.tasks.splice(e(n.tasks,o,r)+1,0,o),n.tasks.length===n.concurrency&&n.saturated(),gt(n.process)})}var i=pn(n,t);return i.push=function(n,t,r){u(i,n,t,r)},delete i.unshift,i}function yn(n,t,r){return un(z(t),n,r)}function mn(n,t){return un($,n,t)}function vn(n,t){var r={},e={};t=t||N;var u=o(function(u){var i=u.pop(),c=t.apply(null,u);c in r?gt(function(){i.apply(null,r[c])}):c in e?e[c].push(i):(e[c]=[i],n.apply(null,u.concat([o(function(n){r[c]=n;var t=e[c];delete e[c];for(var u=0,i=t.length;i>u;u++)t[u].apply(null,n)})])))});return u.memo=r,u.unmemoized=n,u}function dn(n){return o(function(t,r){t.apply(null,r.concat([o(function(t,r){"object"==typeof console&&(t?console.error&&console.error(t):console[n]&&ln(r,function(t){console[n](t)}))})]))})}function gn(n,t){function r(n){return n?e(n):void u(r)}var e=A(t||h),u=G(n);r()}function kn(n,t,r){r=r||h;var e=o(function(t,e){t?r(t):(e.push(u),n.apply(this,e))}),u=function(n,u){return n?r(n):u?void t(e):r(null)};n(u)}function bn(n,t,r){var e=0;return W(function(){return++e<=1||t.apply(this,arguments)},n,r)}function wn(n,t,r){return bn(n,function(){return!t.apply(this,arguments)},r)}function En(n,t,r){var e=0;kn(function(n){return e++<1?n(null,!0):void t.apply(this,arguments)},n,r)}function Sn(n,t){return t}function jn(n,t,r,e){var u=[];n(t,function(n,t,e){r(n,function(n,t){u=u.concat(t||[]),e(n)})},function(n){e(n,u)})}function Ln(){return cn.apply(null,Rt.call(arguments))}function On(n,t){return sn(n,1,t)}function xn(n,t){for(var r=-1,e=n.length;++rr&&(r=Gt(e+r,0)),$n(n,t,r)):-1}function Bn(n,t,r){function e(n){s.unshift(n)}function u(n){var t=qn(s,n);t>=0&&s.splice(t,1)}function i(){a--,ln(s.slice(),function(n){n()})}"function"==typeof arguments[1]&&(r=t,t=null),r=p(r||h);var c=O(n),a=c.length;if(!a)return r(null);t||(t=a);var f={},l=0,s=[];e(function(){a||r(null,f)}),ln(c,function(c){function a(){return t>l&&!v(f,c)&&xn(m,function(n){return v(f,n)})}function s(){a()&&(l++,u(s),h[h.length-1](y,f))}for(var p,h=lt(n[c])?n[c]:[n[c]],y=o(function(n,t){if(l--,t.length<=1&&(t=t[0]),n){var e={};zn(f,function(n,t){e[t]=n}),e[c]=t,r(n,e)}else f[c]=t,gt(i)}),m=h.slice(0,h.length-1),d=m.length;d--;){if(!(p=n[m[d]]))throw new Error("Has inexistant dependency");if(lt(p)&&qn(p,c)>=0)throw new Error("Has cyclic dependencies")}a()?(l++,h[h.length-1](y,f)):e(s)})}function Fn(n){return o(function(t,r){var e=o(function(r){var e=this,u=r.pop();return n(t,function(n,t,u){n.apply(e,r.concat([u]))},u)});return r.length?e.apply(this,r):e})}var Pn,Un="[object Function]",Cn="[object GeneratorFunction]",Dn=Object.prototype,Hn=Dn.toString,Nn=NaN,Qn=/^\s+|\s+$/g,Rn=/^[-+]0x[0-9a-f]+$/i,Wn=/^0b[01]+$/i,Gn=/^0o[0-7]+$/i,Jn=parseInt,Kn=1/0,Vn=1.7976931348623157e308,Xn="Expected a function",Yn=Math.max,Zn="Expected a function",_n=f("length"),nt=9007199254740991,tt=Object.prototype,rt=tt.hasOwnProperty,et=Object.getPrototypeOf,ut=Object.keys,it="[object Arguments]",ot=Object.prototype,ct=ot.hasOwnProperty,at=ot.toString,ft=ot.propertyIsEnumerable,lt=Array.isArray,st="[object String]",pt=Object.prototype,ht=pt.toString,yt=9007199254740991,mt=/^(?:0|[1-9]\d*)$/,vt=Object.prototype,dt="function"==typeof setImmediate&&setImmediate;Pn=dt?function(n){dt(n)}:"object"==typeof process&&"function"==typeof process.nextTick?process.nextTick:function(n){setTimeout(n,0)};var gt=Pn,kt=T(l),bt=M(l),wt=q(l),Et=Array.prototype.slice,St=Q($,Boolean,N),jt=Q($,R,R),Lt=T(Z),Ot=Math.ceil,xt=Math.max,At=M(Z),It=q(Z),Tt=Q(P,Boolean,N),zt=T(fn),Mt=M(fn),$t=q(fn),qt="object"==typeof process&&"function"==typeof process.nextTick?process.nextTick:gt,Bt=dn("log"),Ft=Q(P,R,R),Pt=dn("dir"),Ut=Q(I,N,Sn),Ct=Q(P,N,Sn),Dt=Q($,N,Sn),Ht=o(function(n){var t=[null].concat(n);return function(n){return n.apply(this,t)}}),Nt=T(jn),Qt=q(jn),Rt=Array.prototype.reverse,Wt=An(),Gt=Math.max,Jt=o(function(n,t){return o(function(r){return n.apply(null,t.concat(r))})}),Kt=Fn(I),Vt=Fn($),Xt={applyEach:Vt,applyEachSeries:Kt,apply:Jt,asyncify:c,auto:Bn,cargo:On,compose:Ln,concat:Qt,concatSeries:Nt,constant:Ht,detect:Dt,detectLimit:Ct,detectSeries:Ut,dir:Pt,doDuring:En,doUntil:wn,doWhilst:bn,during:kn,each:H,eachLimit:C,eachOf:$,eachOfLimit:P,eachOfSeries:I,eachSeries:D,ensureAsync:G,every:jt,everyLimit:Ft,filter:wt,filterLimit:bt,filterSeries:kt,forever:gn,iterator:J,log:Bt,map:It,mapLimit:At,mapSeries:Lt,memoize:vn,nextTick:qt,parallel:mn,parallelLimit:yn,priorityQueue:hn,queue:pn,reduce:B,reduceRight:F,reject:$t,rejectLimit:Mt,rejectSeries:zt,retry:an,seq:cn,series:on,setImmediate:gt,some:St,someLimit:Tt,sortBy:en,times:rn,timesLimit:tn,timesSeries:nn,transform:Y,unmemoize:X,until:V,waterfall:K,whilst:W,all:jt,any:St,forEach:H,forEachSeries:D,forEachLimit:C,forEachOf:$,forEachOfSeries:I,forEachOfLimit:P,inject:B,foldl:B,foldr:F,select:wt,selectLimit:bt,selectSeries:kt,wrapSync:c};n["default"]=Xt,n.applyEach=Vt,n.applyEachSeries=Kt,n.apply=Jt,n.asyncify=c,n.auto=Bn,n.cargo=On,n.compose=Ln,n.concat=Qt,n.concatSeries=Nt,n.constant=Ht,n.detect=Dt,n.detectLimit=Ct,n.detectSeries=Ut,n.dir=Pt,n.doDuring=En,n.doUntil=wn,n.doWhilst=bn,n.during=kn,n.each=H,n.eachLimit=C,n.eachOf=$,n.eachOfLimit=P,n.eachOfSeries=I,n.eachSeries=D,n.ensureAsync=G,n.every=jt,n.everyLimit=Ft,n.filter=wt,n.filterLimit=bt,n.filterSeries=kt,n.forever=gn,n.iterator=J,n.log=Bt,n.map=It,n.mapLimit=At,n.mapSeries=Lt,n.memoize=vn,n.nextTick=qt,n.parallel=mn,n.parallelLimit=yn,n.priorityQueue=hn,n.queue=pn,n.reduce=B,n.reduceRight=F,n.reject=$t,n.rejectLimit=Mt,n.rejectSeries=zt,n.retry=an,n.seq=cn,n.series=on,n.setImmediate=gt,n.some=St,n.someLimit=Tt,n.sortBy=en,n.times=rn,n.timesLimit=tn,n.timesSeries=nn,n.transform=Y,n.unmemoize=X,n.until=V,n.waterfall=K,n.whilst=W,n.all=jt,n.any=St,n.forEach=H,n.forEachSeries=D,n.forEachLimit=C,n.forEachOf=$,n.forEachOfSeries=I,n.forEachOfLimit=P,n.inject=B,n.foldl=B,n.foldr=F,n.select=wt,n.selectLimit=bt,n.selectSeries=kt,n.wrapSync=c}); +//# sourceMappingURL=build/async.min.map \ No newline at end of file diff --git a/support/build.test.js b/support/build.test.js index 7cf1908..2342027 100644 --- a/support/build.test.js +++ b/support/build.test.js @@ -16,6 +16,34 @@ describe("async main", function() { }); }); +describe("async umd", function() { + var async; + + before(function() { + async = require("../build/async.js"); + }); + + it("should have methods", function() { + methods.forEach(function(methodName) { + expect(async[methodName]).to.be.a("function"); + }); + }); +}); + +describe("async umd minified", function() { + var async; + + before(function() { + async = require("../build/async.min.js"); + }); + + it("should have methods", function() { + methods.forEach(function(methodName) { + expect(async[methodName]).to.be.a("function"); + }); + }); +}); + methods.forEach(function (methodName) { describe("async." + methodName, function () { var method; -- cgit v1.2.1