Skip to content

Instantly share code, notes, and snippets.

@pH200
Last active December 24, 2015 01:29
Show Gist options
  • Save pH200/6723772 to your computer and use it in GitHub Desktop.
Save pH200/6723772 to your computer and use it in GitHub Desktop.
coke promise
build_assets : function ( config, promise, type, tmp_dir ){
var self = this;
var path = config.path[ type ];
var assets = config[ type ];
return promise.all( Object.keys( assets ).map( function ( group ){
var input = assets[ group ].site ? assets[ group ].site.map( function ( asset ){
return self.pub_dir + path + '/' + asset + '.' + type;
}) : [];
var deffered = Q.defer();
var arg = {
input : input,
output : tmp_dir + group + '.' + type
};
arg.callback = function ( err, stdout, stderr ){
if( err ) deffered.reject( err );
deffered.resolve();
console.log( utils.$good( 'created ' ) + 'combine & minify -> ' + arg.output );
};
packer( arg );
return deffered.promise;
}));
},
build_assets : function ( config, flow, type, tmp_dir ){
var self = this;
var path = config.path[ type ];
var assets = config[ type ];
Object.keys( assets ).forEach( function ( group ){
var input = [];
assets[ group ].site &&
assets[ group ].site.forEach( function ( asset ){
input.push( self.pub_dir + path + '/' + asset + '.' + type );
});
flow.parallel( function ( arg, ready ){
arg.callback = function ( err, stdout, stderr ){
if( err ) throw err;
ready();
console.log( utils.$good( 'created ' ) + 'combine & minify -> ' + arg.output );
};
packer( arg );
}, {
input : input,
output : tmp_dir + group + '.' + type
});
});
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment