ds300 / patch-package

Fix broken node modules instantly 🏃🏽‍♀️💨
MIT License
10.26k stars 287 forks source link

spawn: set encoding utf8 #432

Open milahu opened 1 year ago

milahu commented 1 year ago

so we get pretty error messages

add

   encoding: "utf8",

to

https://github.com/ds300/patch-package/blob/5c2c92bf504885fba4840870a23fc8999c00e572/src/spawnSafe.ts#L10-L13

currently we get binary output, for example

patch-package jest-snapshot 
patch-package 6.5.0
• Creating temporary folder
• Installing jest-snapshot@26.6.2 with yarn
warning package.json: No license field
warning No license field
error Couldn't find any versions for "jest-snapshot" that matches "26.6.2, jest-snapshot@npm:^26.6.2"

{
  status: 1,
  signal: null,
  output: [
    null,
    <Buffer 79 61 72 6e 20 69 6e 73 74 61 6c 6c 20 76 31 2e 32 32 2e 31 39 0a 69 6e 66 6f 20 4e 6f 20 6c 6f 63 6b 66 69 6c 65 20 66 6f 75 6e 64 2e 0a 5b 31 2f 34 ... 113 more bytes>,
    <Buffer 77 61 72 6e 69 6e 67 20 70 61 63 6b 61 67 65 2e 6a 73 6f 6e 3a 20 4e 6f 20 6c 69 63 65 6e 73 65 20 66 69 65 6c 64 0a 77 61 72 6e 69 6e 67 20 4e 6f 20 ... 116 more bytes>
  ],
  pid: 2418758,
  stdout: <Buffer 79 61 72 6e 20 69 6e 73 74 61 6c 6c 20 76 31 2e 32 32 2e 31 39 0a 69 6e 66 6f 20 4e 6f 20 6c 6f 63 6b 66 69 6c 65 20 66 6f 75 6e 64 2e 0a 5b 31 2f 34 ... 113 more bytes>,
  stderr: <Buffer 77 61 72 6e 69 6e 67 20 70 61 63 6b 61 67 65 2e 6a 73 6f 6e 3a 20 4e 6f 20 6c 69 63 65 6e 73 65 20 66 69 65 6c 64 0a 77 61 72 6e 69 6e 67 20 4e 6f 20 ... 116 more bytes>,
  error: null
}