From 8918986c6b05b9b301bd28afe6d57eb6a2cebd16 Mon Sep 17 00:00:00 2001 From: YoungKi Lyu Date: Sat, 1 Oct 2022 20:14:11 +0900 Subject: [PATCH] Improve schema file control in the current folder --- dist/main.cjs | 2 +- dist/main.mjs | 2 +- package-lock.json | 4 ++-- package.json | 2 +- src/schema_to_erd.js | 4 +++- 5 files changed, 8 insertions(+), 6 deletions(-) diff --git a/dist/main.cjs b/dist/main.cjs index 241dac7..e497f43 100644 --- a/dist/main.cjs +++ b/dist/main.cjs @@ -63,7 +63,7 @@ ${E.join(` `)} @enduml -`}async function wo(s,t){let o=await zr.promises.readFile(s,"utf8"),E=Ea(o),T=Uo(E),c=t||Zr.default.parse(s).dir,O=Zr.default.join(c,`${Zr.default.parse(s).name}.puml`);return await zr.promises.mkdir(c,{recursive:!0}),await zr.promises.writeFile(O,T,"utf8"),{pumlFilePath:O,pumlStr:T}}0&&(module.exports={schemaToErd}); +`}async function wo(s,t){let o=await zr.promises.readFile(s,"utf8"),E=Ea(o),T=Uo(E),c=t||Zr.default.parse(s).dir,O=Zr.default.join(c,`${Zr.default.parse(s).name}.puml`);return c&&await zr.promises.mkdir(c,{recursive:!0}),await zr.promises.writeFile(O,T,"utf8"),{pumlFilePath:O,pumlStr:T}}0&&(module.exports={schemaToErd}); /** * @license * Lodash diff --git a/dist/main.mjs b/dist/main.mjs index 060dd23..50249c0 100644 --- a/dist/main.mjs +++ b/dist/main.mjs @@ -63,7 +63,7 @@ ${E.join(` `)} @enduml -`}async function ia(s,t){let o=await go.readFile(s,"utf8"),E=oa(o),T=vo(E),c=t||Mo.parse(s).dir,O=Mo.join(c,`${Mo.parse(s).name}.puml`);return await go.mkdir(c,{recursive:!0}),await go.writeFile(O,T,"utf8"),{pumlFilePath:O,pumlStr:T}}export{ia as schemaToErd}; +`}async function ia(s,t){let o=await go.readFile(s,"utf8"),E=oa(o),T=vo(E),c=t||Mo.parse(s).dir,O=Mo.join(c,`${Mo.parse(s).name}.puml`);return c&&await go.mkdir(c,{recursive:!0}),await go.writeFile(O,T,"utf8"),{pumlFilePath:O,pumlStr:T}}export{ia as schemaToErd}; /** * @license * Lodash diff --git a/package-lock.json b/package-lock.json index 513c3dd..7206f94 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "schema-to-erd", - "version": "1.4.1", + "version": "1.4.2", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "schema-to-erd", - "version": "1.4.1", + "version": "1.4.2", "license": "MIT", "dependencies": { "commander": "^9.4.0", diff --git a/package.json b/package.json index 3186f3c..922aa5f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "schema-to-erd", - "version": "1.4.1", + "version": "1.4.2", "description": "Generate ERD UML file from Schema DDL file", "type": "module", "main": "dist/main.cjs", diff --git a/src/schema_to_erd.js b/src/schema_to_erd.js index 82fc05b..0e31ec4 100644 --- a/src/schema_to_erd.js +++ b/src/schema_to_erd.js @@ -11,7 +11,9 @@ export default async function schemaToErd(schemaFilePath, outputDirPath) { const pumlDirPath = outputDirPath || path.parse(schemaFilePath).dir; const pumlFilePath = path.join(pumlDirPath, `${path.parse(schemaFilePath).name}.puml`); - await fs.mkdir(pumlDirPath, { recursive: true }); + if (pumlDirPath) { + await fs.mkdir(pumlDirPath, { recursive: true }); + } await fs.writeFile(pumlFilePath, pumlStr, 'utf8'); return { pumlFilePath, pumlStr };