forked from angular/angular-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild-schema-dts.js
More file actions
28 lines (23 loc) · 780 Bytes
/
build-schema-dts.js
File metadata and controls
28 lines (23 loc) · 780 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/env node
'use strict';
const fs = require('fs');
const minimist = require('minimist');
// Load the bootstrap.
require('../lib/bootstrap-local');
const SchemaClassFactory = require('@ngtools/json-schema').SchemaClassFactory;
const argv = minimist(process.argv.slice(2));
const inFile = argv._[0];
const outFile = argv._[1];
if (!inFile) {
process.stderr.write('Need to pass in an input file.\n');
process.exit(1);
}
const jsonSchema = JSON.parse(fs.readFileSync(inFile, 'utf-8'));
const SchemaClass = SchemaClassFactory(jsonSchema);
const schemaInstance = new SchemaClass();
const serialized = schemaInstance.$$serialize('text/x.dts', 'CliConfig');
if (outFile) {
fs.writeFileSync(outFile, serialized, 'utf-8');
} else {
process.stdout.write(serialized);
}