-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Run in node.js #3
Comments
@g-rodigy not sure if you're still running into this or not. I ran into a similar issue but was able to get it working using the spawn method: const cp = require('child_process');
const glyphhangerProcess = cp.spawn(
'glyphhanger',
[
// Pass in flags here
'--subset="*.tff"',
],
{ stdio: 'inherit' }
);
glyphhangerProcess.on('close', () => {
console.log('glyphhanger completed');
}); |
Any suggestions on how I could create a glyphhanger gulp task/function in gulpfile.js, perhaps using the above code? Thanks. |
@SamuelMiller , it's been a little while since I wrote a gulp task, but I think the majority of the code above could be repurposed for that. I think the main relevant change would be to call the const cp = require('child_process');
function runGlyphhanger(cb) {
const glyphhangerProcess = cp.spawn(
'glyphhanger',
[
// Pass in flags here
'--subset="*.tff"',
],
{ stdio: 'inherit' }
);
glyphhangerProcess.on('close', () => {
console.log('glyphhanger completed');
// Run `cb` to complete the Gulp task
cb();
});
}
// This assumes this is the only task in this file and you want to export it for
// use in other Gulp files.
// If that's not true you could change this to a call to `series` or
// `parallel` to run this task and other tasks
// @see https://gulpjs.com/docs/en/getting-started/creating-tasks/
exports.default = runGlyphhanger; I haven't tested this code but it seems like it should work. If you try it and get an error let me know and I may be able to help (though I'll be out of the office for the rest of the week after today) |
Thanks for responding. When I return to the part of my current web project that will be using glyphhanger to optimize my fonts, I'll test out the code and get back to you. |
Try // example:
const result = execSync('npx glyphhanger http://localhost:3001').toString();
console.log(result) |
I try run glyphhanger in node like this
It's not working and process never ends. Empirically, I found a place where this happens - here. We waiting for input but it doesn't happen. Can you help me?
The text was updated successfully, but these errors were encountered: