Skip to content

Commit eadcfdd

Browse files
committed
solcjs: Enable import callback without base path (except for --standard-json mode)
1 parent 8352d01 commit eadcfdd

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

solcjs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ function abort (msg) {
3636
}
3737

3838
function readFileCallback(sourcePath) {
39-
sourcePath = program.basePath + '/' + sourcePath;
39+
if (program.basePath)
40+
sourcePath = program.basePath + '/' + sourcePath;
4041
if (fs.existsSync(sourcePath)) {
4142
try {
4243
return { 'contents': fs.readFileSync(sourcePath).toString('utf8') }
@@ -75,7 +76,7 @@ function stripBasePath(sourcePath) {
7576
}
7677

7778
var callbacks = undefined
78-
if (program.basePath)
79+
if (program.basePath || !program.standardJson)
7980
callbacks = {'import': readFileCallback};
8081

8182
if (program.standardJson) {

test/cli.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,7 @@ tape('CLI', function (t) {
6969
'./solcjs --bin ' +
7070
'test/resources/importA.sol ' +
7171
'./test/resources//importA.sol ' +
72-
path.resolve('test/resources/importA.sol') + ' ' +
73-
// Adding importB explicitly here should make compiler find it despite the lack of callback
74-
'test/resources/importB.sol '
72+
path.resolve('test/resources/importA.sol')
7573
);
7674
spt.stderr.empty();
7775
spt.succeeds();

0 commit comments

Comments
 (0)