(file, ...args)
| 24 | const waitForever = () => new Promise((resolve) => resolve); |
| 25 | |
| 26 | const exec = async (file, ...args) => { |
| 27 | return new Promise((resolve, reject) => { |
| 28 | require('child_process').execFile( |
| 29 | file, |
| 30 | args, |
| 31 | { ...process.env }, |
| 32 | (error, stdout, stderr) => { |
| 33 | if (!process.stdout.isTTY) { |
| 34 | stdout = stripAnsi(stdout); |
| 35 | stderr = stripAnsi(stderr); |
| 36 | } |
| 37 | if (error) |
| 38 | reject(new Error(`${[file, ...args]}\n\t${stdout}\n\t${stderr}`)); |
| 39 | |
| 40 | resolve((stdout || stderr).slice(0, -1)); |
| 41 | } |
| 42 | ); |
| 43 | }); |
| 44 | }; |
| 45 | |
| 46 | const mimeType = async (opts) => { |
| 47 | const { path, buffer } = opts; |
no outgoing calls