Created
February 5, 2013 08:02
-
-
Save MoOx/4712964 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
/* | |
* grunt-fontcustom | |
* https://github.com/MoOx/grunt-fontcustom | |
* | |
* Copyright (c) 2013 Maxime Thirouin, contributors | |
* Licensed under the MIT license. | |
*/ | |
'use strict'; | |
module.exports = function (grunt) { | |
var fs = require('fs'); | |
var tmp = require('tmp'); | |
function compile(args, cb) { | |
var child = grunt.util.spawn({ | |
cmd: 'fontcustom', | |
args: args | |
}, function (err, result, code) { | |
if (code === 127) { | |
return grunt.warn( | |
'You need to have Ruby and Fontcustom installed ' + | |
'and in your system PATH for this task to work. ' + | |
'More info: https://github.com/MoOx/grunt-fontcustom' | |
); | |
} | |
}); | |
child.stdout.pipe(process.stdout); | |
child.stderr.pipe(process.stderr); | |
} | |
grunt.registerMultiTask('fontcustom', 'Compile SVG and EPS to Fonts (and CSS)', function () { | |
var args = ['compile']; | |
var helpers = require('grunt-lib-contrib').init(grunt); | |
var options = this.options(); | |
var cb = this.async(); | |
var src; | |
grunt.verbose.writeflags(options, 'Options'); | |
if (!options.src) { | |
grunt.fail.fatal('Missing options `src`'); | |
} | |
src = options.src; | |
if (options.dest) { | |
args.push('--output', options.dest); | |
} | |
// don't want these as CLI flags | |
delete options.src; | |
delete options.dest; | |
// add converted options | |
[].push.apply(args, helpers.optsToArgs(options)); | |
args.push(src); | |
compile(args, cb); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment