Skip to content

Commit

Permalink
feat: clean the codegen input and output folder after generating
Browse files Browse the repository at this point in the history
  • Loading branch information
AllanZhengYP committed Dec 10, 2019
1 parent 3c70d47 commit 6d892f9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion scripts/generate-clients/code-gen.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,4 @@ const spawnProcess = (command, args = [], options = {}) =>
}
});

module.exports = { generateClients };
module.exports = { generateClients, CODE_GEN_INPUT_DIR };
2 changes: 1 addition & 1 deletion scripts/generate-clients/copy-to-clients.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,4 @@ async function copyToClients(clientsDir) {
}
}

module.exports = { copyToClients };
module.exports = { copyToClients, CODE_GEN_OUTPUT_DIR };
7 changes: 5 additions & 2 deletions scripts/generate-clients/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
const yargs = require("yargs");
const path = require("path");
const { generateClients } = require("./code-gen");
const { copyToClients } = require("./copy-to-clients");
const { emptyDirSync } = require("fs-extra");
const { generateClients, CODE_GEN_INPUT_DIR } = require("./code-gen");
const { copyToClients, CODE_GEN_OUTPUT_DIR } = require("./copy-to-clients");

const CLIENTS_DIR = path.normalize(path.join(__dirname, "..", "..", "clients"));

Expand All @@ -20,6 +21,8 @@ const { models, output: clientsDir } = yargs
try {
await generateClients(models);
await copyToClients(clientsDir);
emptyDirSync(CODE_GEN_INPUT_DIR);
emptyDirSync(CODE_GEN_OUTPUT_DIR);
} catch (e) {
console.log(e);
process.exit(1);
Expand Down

0 comments on commit 6d892f9

Please sign in to comment.