From b747704af3b97cc1178607343e3e0e191189ff9d Mon Sep 17 00:00:00 2001 From: nohehf <64989428+nohehf@users.noreply.github.com> Date: Mon, 8 Aug 2022 12:07:24 +0200 Subject: [PATCH] fix: no out directory (#25) v1.0.3 * fix: no out directory * refactor: fmt before merge --- src/index.ts | 6 ++++-- src/lib.ts | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) 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;