compile-schemas-to-typescript
Advanced tools
Comparing version 0.1.0 to 0.2.0
@@ -26,7 +26,16 @@ "use strict"; | ||
} | ||
// create output dir - skip eexist error | ||
try { | ||
yield fs.mkdir(path_1.default.resolve(output)); | ||
} | ||
catch (err) { | ||
if (err.code !== 'EEXIST') | ||
throw err; | ||
} | ||
// get files from input dir | ||
const files = yield fs.readdir(path_1.default.resolve(input)); | ||
for (const file of files) { | ||
if (path_1.default.extname(file) === '.json') { | ||
const ts = yield json_schema_to_typescript_1.compileFromFile(path_1.default.join(input, file)); | ||
yield fs.writeFile(fileOutputPath(file, output), ts); | ||
if (path_1.default.extname(file) === '.json') { // for every `.json` file in the input | ||
const ts = yield json_schema_to_typescript_1.compileFromFile(path_1.default.join(input, file)); // compile to ts | ||
yield fs.writeFile(path_1.default.resolve(fileOutputPath(file, output)), ts); // write to output | ||
} | ||
@@ -33,0 +42,0 @@ } |
{ | ||
"name": "compile-schemas-to-typescript", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"description": "Transform a directory of JSON Schems into TypeScript Interfaces", | ||
"main": "build/index.js", | ||
"types": "build/index.d.ts", | ||
"bin": "build/cli.js", | ||
"scripts": { | ||
@@ -8,0 +9,0 @@ "compile": "tsc -p tsconfig.json", |
@@ -5,2 +5,10 @@ # Compile Schemas to TypeScript | ||
## CLI | ||
This module works as an CLI. Install as a dependency and call `compile-schemas-to-typescript` from a npm script, or use `npx` | ||
```bash | ||
npx compile-schemas-to-typescript <schema-dir> <types-output-dir> | ||
``` | ||
## API | ||
@@ -33,2 +41,2 @@ | ||
Licensed under [MIT](./LICENSE). | ||
Licensed under [MIT](./LICENSE). |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
13004
12
91
41