Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion packages/idea-transformer/src/Transformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,14 @@ export default class Transformer<T extends Record<string, unknown>> {
if (!fs.existsSync(this.input)) {
throw Exception.for('Input file %s does not exist', this.input);
}
//read input file
const content = fs.readFileSync(this.input, 'utf8');
//parse schema
const schema = parse(fs.readFileSync(this.input, 'utf8'));
const schema: SchemaConfig = path.extname(this.input) === '.json'
//parse directly
? JSON.parse(content)
//parse as normal
: parse(content);
//look for use
if (Array.isArray(schema.use)) {
schema.use.forEach((file: string) => {
Expand Down
11 changes: 11 additions & 0 deletions packages/idea-transformer/tests/Terminal.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,17 @@ describe('Terminal Tests', () => {
}
}).timeout(20000);

it('Should run cli using json file', async () => {
const terminal = new Terminal(['transform', '-i', './schema.json'], { cwd });
expect(terminal.cwd).to.equal(cwd);
await terminal.run();
const out = path.join(cwd, 'out/enums.ts');
const exists = fs.existsSync(out);
expect(exists).to.be.true;
if (exists) {
fs.unlinkSync(out);
}
}).timeout(20000);
/*
* UNIT TEST TO COVER THE UNCOVERED LINES
*/
Expand Down
Loading