freebuff 0.0.105 → 0.0.107

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +20 -10
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -705,6 +705,11 @@ function printSpawnFailure(err) {
705
705
  console.error('')
706
706
  }
707
707
 
708
+ function exitOnSpawnFailure(err) {
709
+ printSpawnFailure(err)
710
+ process.exit(1)
711
+ }
712
+
708
713
  function spawnInstalledBinary(options = {}) {
709
714
  if (!fs.existsSync(CONFIG.binaryPath)) {
710
715
  try {
@@ -716,19 +721,24 @@ function spawnInstalledBinary(options = {}) {
716
721
  `downloaded binary is missing at ${CONFIG.binaryPath}`,
717
722
  )
718
723
  error.code = 'BINARY_MISSING'
719
- printSpawnFailure(error)
720
- process.exit(1)
724
+ exitOnSpawnFailure(error)
721
725
  }
722
726
 
723
- const child = spawn(CONFIG.binaryPath, process.argv.slice(2), {
724
- stdio: 'inherit',
725
- ...options,
726
- })
727
+ // spawn() only emits 'error' asynchronously for a few errno values
728
+ // (EACCES, EAGAIN, EMFILE, ENFILE, ENOENT); everything else — notably
729
+ // UNKNOWN on Windows when antivirus or Smart App Control blocks the
730
+ // exe or the download is corrupt — is thrown synchronously.
731
+ let child
732
+ try {
733
+ child = spawn(CONFIG.binaryPath, process.argv.slice(2), {
734
+ stdio: 'inherit',
735
+ ...options,
736
+ })
737
+ } catch (err) {
738
+ exitOnSpawnFailure(err)
739
+ }
727
740
 
728
- child.on('error', (err) => {
729
- printSpawnFailure(err)
730
- process.exit(1)
731
- })
741
+ child.on('error', exitOnSpawnFailure)
732
742
 
733
743
  return child
734
744
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "freebuff",
3
- "version": "0.0.105",
3
+ "version": "0.0.107",
4
4
  "description": "The world's strongest free coding agent",
5
5
  "license": "MIT",
6
6
  "bin": {