diff --git a/src/index.ts b/src/index.ts index 8cea494..8fc21b6 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,5 +1,6 @@ import { createPostmanCollection, saveJsonFormatted } from "./lib.ts"; import { parse } from "https://deno.land/std@0.149.0/flags/mod.ts"; +import { ensureDirSync } from "https://deno.land/std@0.151.0/fs/mod.ts"; function help() { console.log(`Error: not enough arguments. @@ -36,8 +37,9 @@ console.log(`Creating the postman collection for ${url}`); const collection = await createPostmanCollection(url, authorization); -path = path || "out/" + collection.info.name + ".postman_collection.json"; +path = path || "./out/" + collection.info.name + ".postman_collection.json"; +ensureDirSync("./out/"); saveJsonFormatted(collection, path); - console.log(`Collection saved at ${path}`); + console.log(`Import it in postman and complete the queries ! 🚀`); diff --git a/src/lib.ts b/src/lib.ts index 414c4df..fa07600 100644 --- a/src/lib.ts +++ b/src/lib.ts @@ -58,7 +58,9 @@ function findType( } export function saveJsonFormatted(json: any, path: string) { - Deno.writeTextFileSync(path, JSON.stringify(json, null, "\t")); + Deno.writeTextFileSync(path, JSON.stringify(json, null, "\t"), { + create: true, + }); } interface Argument { formatedType: string;