Last active
January 3, 2016 04:38
-
-
Save ianstormtaylor/8409952 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var shorthands = require('./shorthands'); | |
/** | |
* Mixin shorthands. | |
*/ | |
for (var key in shorthands) Builder.prototype[key] = shorthands[key]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Expose `exprts`. | |
*/ | |
module.exports = exprts; | |
/** | |
* Exports plugin example. | |
* | |
* @param {String} type | |
*/ | |
function exprts (type) { | |
return function (build, fn) { | |
setImmediate(fn); | |
build.each(type, function (file) { | |
if (!file.contents) return; | |
file.contents = 'module.exports = ' + file.contents; | |
}); | |
}); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var str2js = require('string-to-js'); | |
/** | |
* Expose `string`. | |
*/ | |
module.exports = string; | |
/** | |
* String plugin example. | |
* | |
* @param {String} type | |
*/ | |
function string (type) { | |
return function (build, fn) { | |
setImmediate(fn); | |
build.each(type, function (file) { | |
if (!file.contents) return; | |
file.contents = str2js(file.contents); | |
}); | |
}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var concat = require('./plugins/concat'); | |
var copy = require('./plugins/copy'); | |
var string = require('./plugins/string'); | |
var exps = require('./plugins/exports'); | |
/** | |
* Build scripts shorthand. | |
* | |
* @param {Function} fn | |
*/ | |
exports.scripts = function (fn) { | |
this | |
.use(concat('scripts')) | |
.build(fn); | |
}; | |
/** | |
* Build styles shorthand. | |
* | |
* @param {Function} fn | |
*/ | |
exports.styles = function (fn) { | |
this | |
.use(concat('styles')) | |
.build(fn); | |
}; | |
/** | |
* Build templates shorthand. | |
* | |
* @param {Function} fn | |
*/ | |
exports.templates = function (fn) { | |
this | |
.use(string('templates')) | |
.use(concat('templates')) | |
.build(fn); | |
}; | |
/** | |
* Build json shorthand. | |
* | |
* @param {Function} fn | |
*/ | |
exports.json = function (fn) { | |
this | |
.use(exps('json')) | |
.use(concat('json')) | |
.build(fn); | |
}; | |
/** | |
* Build images shorthand. | |
* | |
* @param {Function} fn | |
*/ | |
exports.images = function (fn) { | |
this | |
.use(copy('images')) | |
.build(fn); | |
}; | |
/** | |
* Build fonts shorthand. | |
* | |
* @param {Function} fn | |
*/ | |
exports.fonts = function (fn) { | |
this | |
.use(copy('fonts')) | |
.build(fn); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
i'm not totally sure about what's going on here, but why not something like: