From 83ded61891742391cbb24a16e13a8618fdca5ab2 Mon Sep 17 00:00:00 2001 From: Julian Xhokaxhiu Date: Tue, 17 Feb 2015 09:20:19 +0100 Subject: [PATCH] Replace execSync with sync-exec --- README.md | 16 ++++++++-------- fontfacegen.js | 18 +++++++++--------- package.json | 2 +- test.js | 4 ++-- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index de2f8ab..cccf5b8 100644 --- a/README.md +++ b/README.md @@ -98,28 +98,28 @@ Note: If present, the json config file must be valid json. var fs = require('fs'); var path = require('path'); - var sh = require('execSync'); + var exec = require('sync-exec'); var fontfacegen = require('./fontfacegen'); - var source = 'assets/fonts/'; - var dest = 'fonts/'; + var source = 'tmp/'; + var dest = 'tmp/dest/'; var fonts = fs.readdirSync(source); - sh.exec('rm -rf ' + dest); + exec('rm -rf ' + dest); for (var i = fonts.length - 1; i >= 0; i--) { var font = fonts[i]; var extension = path.extname(font); var fontname = path.basename(font, extension); + // Test with embedded ttf if (extension == '.ttf' || extension == '.otf') { fontfacegen({ source: path.join(source, font), dest: dest, - css: dest + 'css/' + fontname + '.css', - css_fontpath: '../fonts/' + fontname, - collate: true, - embed: ['woff', 'ttf'] + css_fontpath: '../fonts/', + embed: ['ttf'], + collate: true }); } }; diff --git a/fontfacegen.js b/fontfacegen.js index 3873903..d9380c6 100644 --- a/fontfacegen.js +++ b/fontfacegen.js @@ -12,7 +12,7 @@ var fs = require('fs'), path = require('path'), -sh = require('execSync'), +exec = require('sync-exec'), mkdirp = require('mkdirp'), requiredCommands = ['fontforge', 'ttfautohint', 'ttf2eot', 'batik-ttf2svg'], @@ -237,8 +237,8 @@ merge = function(destination, source) { }, commandPath = function(command) { - var result = sh.exec('which ' + command); - if (result.code == 0) + var result = exec('which ' + command); + if (result.status == 0) return result.stdout.trim(); return false; }, @@ -260,8 +260,8 @@ fontforge = function() { command += ' \'' + arg + '\''; }); - result = sh.exec(command + ' 2> /dev/null'); - success = (result.code == 0); + result = exec(command + ' 2> /dev/null'); + success = (result.status == 0); if (! success) { throw new FontFaceException( @@ -278,8 +278,8 @@ ttf2eot = function(source, dest) { command = [globals.ttf2eot, quote(source), '>', quote(dest)].join(' '); - result = sh.exec(command); - success = (result.code == 0); + result = exec(command); + success = (result.status == 0); if (! success) { throw new FontFaceException( @@ -295,8 +295,8 @@ ttf2svg = function(source, target, name) { var command, result, success; command = [globals['batik-ttf2svg'], quote(source), '-id', quote(name), '-o', quote(target)].join(' '); - result = sh.exec(command); - success = (result.code == 0); + result = exec(command); + success = (result.status == 0); if (! success) { throw new FontFaceException( diff --git a/package.json b/package.json index c05fdac..9624232 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "css" ], "dependencies": { - "execSync": "~1.0.1-pre", + "sync-exec": "^0.4.0", "mkdirp": "^0.3.5" } } diff --git a/test.js b/test.js index d4e63a3..a69d3bb 100644 --- a/test.js +++ b/test.js @@ -1,14 +1,14 @@ var fs = require('fs'); var path = require('path'); -var sh = require('execSync'); +var exec = require('sync-exec'); var fontfacegen = require('./fontfacegen'); var source = 'tmp/'; var dest = 'tmp/dest/'; var fonts = fs.readdirSync(source); -sh.exec('rm -rf ' + dest); +exec('rm -rf ' + dest); for (var i = fonts.length - 1; i >= 0; i--) { var font = fonts[i];