Skip to content

Commit 06727a6

Browse files
committed
Upgrade 'commander' dependency to the latest version
- New version allows having parameters that take multiple values
1 parent 250c85b commit 06727a6

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
"homepage": "https://github.com/ethereum/solc-js#readme",
4747
"dependencies": {
4848
"command-exists": "^1.2.8",
49-
"commander": "3.0.2",
49+
"commander": "^8.1.0",
5050
"follow-redirects": "^1.12.1",
5151
"fs-extra": "^0.30.0",
5252
"js-sha3": "0.8.0",

solcjs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ var smtsolver = require('./smtsolver.js');
1414
process.removeAllListeners('uncaughtException');
1515
var commander = require('commander');
1616

17-
var program = new commander.Command();
17+
const program = new commander.Command();
1818
program.name('solcjs');
1919
program.version(solc.version());
2020
program
@@ -26,18 +26,19 @@ program
2626
.option('--base-path <path>', 'Automatically resolve all imports inside the given path.')
2727
.option('-o, --output-dir <output-directory>', 'Output directory for the contracts.');
2828
program.parse(process.argv);
29+
const options = program.opts();
2930

3031
var files = program.args;
31-
var destination = program.outputDir || '.'
32+
var destination = options.outputDir || '.'
3233

3334
function abort (msg) {
3435
console.error(msg || 'Error occured');
3536
process.exit(1);
3637
}
3738

3839
function readFileCallback(sourcePath) {
39-
if (program.basePath)
40-
sourcePath = program.basePath + '/' + sourcePath;
40+
if (options.basePath)
41+
sourcePath = options.basePath + '/' + sourcePath;
4142
if (fs.existsSync(sourcePath)) {
4243
try {
4344
return { 'contents': fs.readFileSync(sourcePath).toString('utf8') }
@@ -57,7 +58,7 @@ function withUnixPathSeparators(filePath) {
5758
}
5859

5960
function stripBasePath(sourcePath) {
60-
const absoluteBasePath = (program.basePath ? path.resolve(program.basePath) : path.resolve('.'));
61+
const absoluteBasePath = (options.basePath ? path.resolve(options.basePath) : path.resolve('.'));
6162

6263
// Compared to base path stripping logic in solc this is much simpler because path.resolve()
6364
// handles symlinks correctly (does not resolve them except in work dir) and strips .. segments
@@ -76,10 +77,10 @@ function stripBasePath(sourcePath) {
7677
}
7778

7879
var callbacks = undefined
79-
if (program.basePath || !program.standardJson)
80+
if (options.basePath || !options.standardJson)
8081
callbacks = {'import': readFileCallback};
8182

82-
if (program.standardJson) {
83+
if (options.standardJson) {
8384
var input = fs.readFileSync(process.stdin.fd).toString('utf8');
8485
var output = solc.compile(input, callbacks);
8586

@@ -112,7 +113,7 @@ if (program.standardJson) {
112113
process.exit(1);
113114
}
114115

115-
if (!(program.bin || program.abi)) {
116+
if (!(options.bin || options.abi)) {
116117
abort('Invalid option selected, must specify either --bin or --abi');
117118
}
118119

@@ -130,7 +131,7 @@ var output = JSON.parse(solc.compile(JSON.stringify({
130131
language: 'Solidity',
131132
settings: {
132133
optimizer: {
133-
enabled: program.optimize
134+
enabled: options.optimize
134135
},
135136
outputSelection: {
136137
'*': {
@@ -173,11 +174,11 @@ for (var fileName in output.contracts) {
173174
var contractFileName = fileName + ':' + contractName;
174175
contractFileName = contractFileName.replace(/[:./\\]/g, '_');
175176

176-
if (program.bin) {
177+
if (options.bin) {
177178
writeFile(contractFileName + '.bin', output.contracts[fileName][contractName].evm.bytecode.object);
178179
}
179180

180-
if (program.abi) {
181+
if (options.abi) {
181182
writeFile(contractFileName + '.abi', JSON.stringify(output.contracts[fileName][contractName].abi));
182183
}
183184
}

0 commit comments

Comments
 (0)