insomnia/packages/insomnia-app/app/network/grpc/write-proto-file.js
2020-11-10 13:30:27 +13:00

16 lines
389 B
JavaScript

// @flow
import path from 'path';
import os from 'os';
import mkdirp from 'mkdirp';
import fs from 'fs';
const writeProtoFile = async (src: string): Promise<string> => {
const root = path.join(os.tmpdir(), 'insomnia-grpc');
mkdirp.sync(root);
const p = path.join(root, `${Math.random()}.proto`);
await fs.promises.writeFile(p, src);
return p;
};
export default writeProtoFile;