Commit d5b2491b authored by rockyl's avatar rockyl

cli wrapper

parent 92bda91c
...@@ -8,7 +8,7 @@ const fs = require('fs-extra'); ...@@ -8,7 +8,7 @@ const fs = require('fs-extra');
const {generateDeclareMap} = require('../src/index'); const {generateDeclareMap} = require('../src/index');
exports.execute = async function (program) { exports.execute = async function (program) {
if (!program.input || !program.output) { if (!program.input) {
console.warn('parameter is incorrect'); console.warn('parameter is incorrect');
process.exit(1); process.exit(1);
} }
...@@ -19,6 +19,7 @@ exports.execute = async function (program) { ...@@ -19,6 +19,7 @@ exports.execute = async function (program) {
const inputFile = program.input; const inputFile = program.input;
const inputFileFolder = path.dirname(inputFile); const inputFileFolder = path.dirname(inputFile);
const outputFile = path.join(inputFileFolder, 'declare.json');
const projectPath = process.cwd(); const projectPath = process.cwd();
...@@ -28,7 +29,7 @@ exports.execute = async function (program) { ...@@ -28,7 +29,7 @@ exports.execute = async function (program) {
const result = generateDeclareMap( const result = generateDeclareMap(
tsconfig, tsconfig,
program.input, inputFile,
componentsSrcPath, componentsSrcPath,
projectPath, projectPath,
null, null,
...@@ -44,6 +45,5 @@ exports.execute = async function (program) { ...@@ -44,6 +45,5 @@ exports.execute = async function (program) {
process.exit(2); process.exit(2);
} }
fs.ensureDirSync(path.dirname(program.output)); fs.writeJsonSync(outputFile, result.declareMap);
fs.writeJsonSync(program.output, result.declareMap); };
}
...@@ -12,7 +12,6 @@ program ...@@ -12,7 +12,6 @@ program
.version('1.0.3') .version('1.0.3')
.description('scilla declare generator') .description('scilla declare generator')
.option('-i, --input [string]', 'input file') .option('-i, --input [string]', 'input file')
.option('-o, --output [string]', 'output file')
.option('-p, --projectPath [string]', 'path of components') .option('-p, --projectPath [string]', 'path of components')
.option('-v, --verbose [boolean]', 'verbose mode', false) .option('-v, --verbose [boolean]', 'verbose mode', false)
.parse(process.argv); .parse(process.argv);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment