Skip to content

Commit 30b7a42

Browse files
axicLeonardo Alt
authored andcommitted
Fix --standard-json on solcjs
1 parent 0bb4853 commit 30b7a42

File tree

2 files changed

+31
-9
lines changed

2 files changed

+31
-9
lines changed

solcjs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,8 @@ function abort (msg) {
5151
}
5252

5353
if (argv['standard-json']) {
54-
var size = fs.fstatSync(process.stdin.fd).size;
55-
56-
if (size <= 0) {
57-
abort('Empty input was read');
58-
}
59-
60-
var input = fs.readSync(process.stdin.fd, size)[0];
61-
62-
console.log(solc.compileStandardWrapper(input));
54+
var input = fs.readFileSync(process.stdin.fd);
55+
console.log(solc.compile(input.toString('utf8')))
6356
process.exit(0);
6457
} else if (files.length === 0) {
6558
console.error('Must provide a file');

test/cli.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,33 @@ tape('CLI', function (t) {
6262
spt.succeeds();
6363
spt.end();
6464
});
65+
66+
t.test('standard json', function (st) {
67+
var input = {
68+
'language': 'Solidity',
69+
'settings': {
70+
'outputSelection': {
71+
'*': {
72+
'*': [ 'evm.bytecode', 'userdoc' ]
73+
}
74+
}
75+
},
76+
'sources': {
77+
'Contract.sol': {
78+
'content': 'pragma solidity ^0.5.0; contract Contract { function f() pure public {} }'
79+
}
80+
}
81+
};
82+
var spt = spawn(st, './solcjs --standard-json');
83+
spt.stdin.setEncoding('utf-8');
84+
spt.stdin.write(JSON.stringify(input));
85+
spt.stdin.end();
86+
spt.stdin.on('finish', function () {
87+
spt.stderr.empty();
88+
spt.stdout.match(/Contract.sol/);
89+
spt.stdout.match(/userdoc/);
90+
spt.succeeds();
91+
spt.end();
92+
});
93+
});
6594
});

0 commit comments

Comments
 (0)