Skip to content
This repository has been archived by the owner on Feb 18, 2021. It is now read-only.

Commit

Permalink
Use stdio rather than command line parameters to pass list of files t…
Browse files Browse the repository at this point in the history
…o phantomjs

Avoids the ENAMETOOLONG error on Windows with a large number of files.

Fixed #17.
  • Loading branch information
MatmaRex committed Feb 20, 2015
1 parent 52fa71e commit e5f57c7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
3 changes: 2 additions & 1 deletion tasks/lib/svg2png.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
*/

var fs = require('fs'),
system = require('system'),
page = require('webpage').create(),
files = JSON.parse(phantom.args[0]),
files = JSON.parse(system.stdin.read()),
total = files.length,
next = 0,

Expand Down
26 changes: 13 additions & 13 deletions tasks/svg2png.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,20 +99,12 @@ module.exports = function(grunt)
process.stdout.write(str + (hasTerminal ? '' : "\n"));
};

var spawn = grunt.util.spawn({
cmd: phantomjs.path,
args: [
path.resolve(__dirname, 'lib/svg2png.js'),
JSON.stringify(files)
]
},
function(err, result, code)
{
grunt.log.write("\n");
grunt.log.ok("Rasterization complete.");
done();
}
var spawn = require('child_process').spawn(
phantomjs.path,
[ path.resolve(__dirname, 'lib/svg2png.js') ]
);
spawn.stdin.write(JSON.stringify(files));
spawn.stdin.end();

spawn.stdout.on('data', function(buffer)
{
Expand All @@ -125,6 +117,14 @@ module.exports = function(grunt)
} catch (e) { }
});

spawn.on('exit', function()
{
update();
grunt.log.write("\n");
grunt.log.ok("Rasterization complete.");
done();
});

update();
});
};

0 comments on commit e5f57c7

Please sign in to comment.