annotate node_modules/static/tasks/static.js @ 101:52e44ee1c791 tip master

enabled all scores in autostart script
author Rob Canning <rc@kiben.net>
date Tue, 21 Apr 2015 16:20:57 +0100
parents 333afcfd3f3a
children
rev   line source
rc-web@69 1 module.exports = function(grunt) {
rc-web@69 2 var path = require('path'),
rc-web@69 3 fs = require('fs'),
rc-web@69 4 static = require('static'),
rc-web@69 5 async = require('async'),
rc-web@69 6 _ = require('underscore');
rc-web@69 7
rc-web@69 8 grunt.registerMultiTask('static', "Process files with static", function() {
rc-web@69 9 var done = this.async();
rc-web@69 10 var config = this.data;
rc-web@69 11 if (config.require) {
rc-web@69 12 var deps = typeof config.require === 'string' ? [config.require] : config.require;
rc-web@69 13 _.each(deps, function(dep) {
rc-web@69 14 require(path.join(process.cwd(), dep))(static);
rc-web@69 15 });
rc-web@69 16 }
rc-web@69 17 async.series(_.map(config.build, function(source, target) {
rc-web@69 18 return function(complete) {
rc-web@69 19 var sources = typeof source === 'string' ? [source] : source,
rc-web@69 20 output = '';
rc-web@69 21 async.series(sources.map(function(source) {
rc-web@69 22 return function(next) {
rc-web@69 23 static.transform(typeof source === 'object' ? source.file : source, function(buffer) {
rc-web@69 24 output += buffer.toString();
rc-web@69 25 next();
rc-web@69 26 }, typeof source === 'object' ? source.context: undefined);
rc-web@69 27 }
rc-web@69 28 }), function() {
rc-web@69 29 console.log('grunt.static: wrote ' + target);
rc-web@69 30 grunt.file.write(target, output);
rc-web@69 31 complete();
rc-web@69 32 });
rc-web@69 33 }
rc-web@69 34 }), function() {
rc-web@69 35 done(true);
rc-web@69 36 });
rc-web@69 37 });
rc-web@69 38 };