Skip to content

Commit

Permalink
Merge pull request #1 from julianxhokaxhiu/develop
Browse files Browse the repository at this point in the history
Replace execSync with sync-exec
  • Loading branch information
Brock Riemenschneider committed Feb 25, 2015
2 parents 547e4b9 + 83ded61 commit 2af759c
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 20 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
});
}
};
18 changes: 9 additions & 9 deletions fontfacegen.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand Down Expand Up @@ -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;
},
Expand All @@ -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(
Expand All @@ -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(
Expand All @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"css"
],
"dependencies": {
"execSync": "~1.0.1-pre",
"sync-exec": "^0.4.0",
"mkdirp": "^0.3.5"
}
}
4 changes: 2 additions & 2 deletions test.js
Original file line number Diff line number Diff line change
@@ -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];
Expand Down

0 comments on commit 2af759c

Please sign in to comment.