function spawn(filePath, args, stdout, stderr) {
    return new Promise((resolve, reject) => {
        const child = cp.spawn(
            process.execPath,
            [filePath].concat(args),
            { stdio: "pipe" }
        )
        const out = new BufferStream()
        const error = new BufferStream()

        if (stdout != null) {
            child.stdout.pipe(stdout)
        }
        if (stderr != null) {
            child.stderr.pipe(stderr)
        }
        else {
            child.stderr.pipe(error)
        }
        child.stdout.pipe(out)
        child.on("close", (exitCode) => {
            if (exitCode) {
                reject(new Error(error.value || "Exited with non-zero code."))
            }
            else {
                resolve()
            }
        })
        child.on("error", reject)
    })
}
Spawns the given script with the given arguments.

@param {string} filePath - The file path to be executed.
@param {string[]} args - The arguments to execute.
@param {Writable} [stdout] - The writable stream to receive stdout.
@param {Writable} [stderr] - The writable stream to receive stderr.
@returns {Promise<void>} The promise which becomes fulfilled if the child
 process finished.