Skip to content

Commit

Permalink
update deps
Browse files Browse the repository at this point in the history
  • Loading branch information
Evgeny Metelkin committed Nov 26, 2023
1 parent 0c09444 commit 8409523
Show file tree
Hide file tree
Showing 3 changed files with 612 additions and 628 deletions.
41 changes: 22 additions & 19 deletions bin/heta-run.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,26 @@ commander
.description('Run heta files, return JavaScript object')
.usage('[inputFile]')
.option('-o, --output <path>', 'save result to json file')
.action((input, cmd) => {
fs.readFile(input, 'utf8', (err, contents) => {
if (input.match(/.heta$/) === null) throw new Error('Incorrect file type');

if (err) {
process.stderr.write(err.message);
} else {
let result = parse(contents);
if (cmd.output) {
fs.writeFile(cmd.output, JSON.stringify(result, null, 2), (err) => {
if (err) throw err;
process.stdout.write(`Result successfully written to file: ${cmd.output}.`);
});
} else {
process.stdout.write(JSON.stringify(result, null, 2));
}
}
});
})
.parse(process.argv);


let input = commander.args[0];
let opts = commander.opts();

fs.readFile(input, 'utf8', (err, contents) => {
if (input.match(/.heta$/) === null) throw new Error('Incorrect file type');

if (err) {
process.stderr.write(err.message);
} else {
let result = parse(contents);
if (opts.output) {
fs.writeFile(opts.output, JSON.stringify(result, null, 2), (err) => {
if (err) throw err;
process.stdout.write(`Result successfully written to file: ${opts.output}.`);
});
} else {
process.stdout.write(JSON.stringify(result, null, 2));
}
}
});
Loading

0 comments on commit 8409523

Please sign in to comment.