Skip to content

Commit

Permalink
chore: prettify models afer copying
Browse files Browse the repository at this point in the history
  • Loading branch information
trivikr committed Nov 12, 2020
1 parent b3ddb3f commit b288f4c
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions scripts/copy-models/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const yargs = require("yargs");

const { promises: fsPromises } = require("fs");
const { join } = require("path");
const { spawnProcess } = require("../generate-clients/spawn-process");

const { models } = yargs
.alias("m", "models")
Expand All @@ -12,6 +13,7 @@ const { models } = yargs
.help().argv;

(async () => {
const OUTPUT_DIR = join(__dirname, "..", "..", "codegen", "sdk-codegen", "aws-models");
const files = await fsPromises.readdir(models.toString(), {
withFileTypes: true,
});
Expand All @@ -38,15 +40,7 @@ const { models } = yargs
const version = fileContent.match(versionRE)[1];

// Copy file.
const outputFile = join(
__dirname,
"..",
"..",
"codegen",
"sdk-codegen",
"aws-models",
`${sdkId}.${version}.json`
);
const outputFile = join(OUTPUT_DIR, `${sdkId}.${version}.json`);
await fsPromises.writeFile(outputFile, fileContent);
} catch (e) {
// Copy failed, log.
Expand All @@ -58,4 +52,10 @@ const { models } = yargs
console.log(e.message);
}
}

// Prettify copied models
await spawnProcess(join(__dirname, "..", "..", "node_modules", ".bin", "prettier"), [
"--write",
`${OUTPUT_DIR}/*.json`,
]);
})();

0 comments on commit b288f4c

Please sign in to comment.