-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcmd.js
More file actions
executable file
·34 lines (28 loc) · 816 Bytes
/
cmd.js
File metadata and controls
executable file
·34 lines (28 loc) · 816 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
29
30
31
32
33
34
#!/usr/bin/env node
'use strict';
(function () {
var SolidityParser, echo, file, fs, i, len, ref, src;
fs = require('fs');
SolidityParser = require('./index.js');
echo = function (msg) {
return process.stdout.write(`${JSON.stringify(msg, null, 2)}\n`);
};
if (process.argv.length > 2) {
ref = process.argv.slice(2);
for (i = 0, len = ref.length; i < len; i++) {
file = ref[i];
src = fs.readFileSync(file, 'utf8');
try {
echo(SolidityParser.parse(src));
} catch (err) {
process.stderr.write(
err.name === 'SyntaxError'
? 'Location: ' + JSON.stringify(err.location, null, 4) + '\n' + err
: err.name + ': ' + err.message,
);
}
}
} else {
echo('Solidity Parser: file...');
}
}.call(this));