🔧 pass object

This commit is contained in:
ful1e5 2020-09-01 16:47:23 +05:30
parent 24aaa0a993
commit 7a73fec48a

View file

@ -1,12 +1,19 @@
import { exists, mkdir, writeFile } from "fs"; import { resolve } from "path";
import { exists, mkdirSync, writeFileSync } from "fs";
const writeSchemaData = (location: string, content: string) => { interface WriteSchemaData {
exists(location, (exists) => { path: string;
content: string;
fileName: string;
}
const writeSchemaData = ({ path, content, fileName }: WriteSchemaData) => {
exists(path, (exists) => {
if (!exists) { if (!exists) {
mkdir(location, { recursive: true }, () => {}); mkdirSync(path, { recursive: true });
} }
}); });
writeFile(location, content, "utf-8", () => {}); writeFileSync(resolve(path, fileName), content);
}; };
export { writeSchemaData }; export { writeSchemaData };