Commit d5b2491b authored by rockyl's avatar rockyl

cli wrapper

parent 92bda91c
......@@ -8,7 +8,7 @@ const fs = require('fs-extra');
const {generateDeclareMap} = require('../src/index');
exports.execute = async function (program) {
if (!program.input || !program.output) {
if (!program.input) {
console.warn('parameter is incorrect');
process.exit(1);
}
......@@ -19,6 +19,7 @@ exports.execute = async function (program) {
const inputFile = program.input;
const inputFileFolder = path.dirname(inputFile);
const outputFile = path.join(inputFileFolder, 'declare.json');
const projectPath = process.cwd();
......@@ -28,7 +29,7 @@ exports.execute = async function (program) {
const result = generateDeclareMap(
tsconfig,
program.input,
inputFile,
componentsSrcPath,
projectPath,
null,
......@@ -44,6 +45,5 @@ exports.execute = async function (program) {
process.exit(2);
}
fs.ensureDirSync(path.dirname(program.output));
fs.writeJsonSync(program.output, result.declareMap);
}
fs.writeJsonSync(outputFile, result.declareMap);
};
......@@ -12,7 +12,6 @@ program
.version('1.0.3')
.description('scilla declare generator')
.option('-i, --input [string]', 'input file')
.option('-o, --output [string]', 'output file')
.option('-p, --projectPath [string]', 'path of components')
.option('-v, --verbose [boolean]', 'verbose mode', false)
.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