zachleat / glyphhanger

Your web font utility belt. It can subset web fonts. It can find unicode-ranges for you automatically. It makes julienne fries.
https://www.zachleat.com/web/glyphhanger/
MIT License
748 stars 21 forks source link

Doesn't work with async child_process functions in Nodejs #23

Open neurocmd opened 1 year ago

neurocmd commented 1 year ago

I'm trying to run glyphhanger console command with child_process exec function and it hangs and the process never ends. But with execSync it works

This works

execSync(
  `npx glyphhanger --subset=*.ttf --formats=woff2,woff --output=.`
)

But this doesn't

exec(`npx glyphhanger --subset=*.ttf --formats=woff2,woff --output=.`, (error, stdout, stderr) => {
  if (error) {
    console.error(`Error: ${error.message}`)
    return
  }
  if (stderr) {
    console.error(`stderr: ${stderr}`)
    return
  }
  console.log(`stdout:\n${stdout}`)
})

Had to resort to spawn with these options

{
  shell: true,
  stdio: 'inherit'
}

Maybe it has something to do with Python libraries?