aboutsummaryrefslogtreecommitdiffstats
path: root/packages/deployer/src/cli.ts
diff options
context:
space:
mode:
authorAmir Bandeali <abandeali1@gmail.com>2018-02-15 06:03:12 +0800
committerAmir Bandeali <abandeali1@gmail.com>2018-02-16 02:13:06 +0800
commitf62762bd0e5d3be443e412df1829c2d89ef4640e (patch)
tree170aba9754bb867c71ab06e6141bc4672f9aa85f /packages/deployer/src/cli.ts
parent4b6735227876913aa70c22e1d57f547f97201a3a (diff)
downloaddexon-0x-contracts-f62762bd0e5d3be443e412df1829c2d89ef4640e.tar.gz
dexon-0x-contracts-f62762bd0e5d3be443e412df1829c2d89ef4640e.tar.zst
dexon-0x-contracts-f62762bd0e5d3be443e412df1829c2d89ef4640e.zip
Add contracts to compiler options
Diffstat (limited to 'packages/deployer/src/cli.ts')
-rw-r--r--packages/deployer/src/cli.ts21
1 files changed, 21 insertions, 0 deletions
diff --git a/packages/deployer/src/cli.ts b/packages/deployer/src/cli.ts
index 0fe412bdf..5e0f2145b 100644
--- a/packages/deployer/src/cli.ts
+++ b/packages/deployer/src/cli.ts
@@ -14,6 +14,7 @@ const DEFAULT_ARTIFACTS_DIR = path.resolve('artifacts');
const DEFAULT_NETWORK_ID = 50;
const DEFAULT_JSONRPC_PORT = 8545;
const DEFAULT_GAS_PRICE = (10 ** 9 * 2).toString();
+const DEFAULT_COMPILE_CONTRACTS = '*';
/**
* Compiles all contracts with options passed in through CLI.
@@ -25,6 +26,7 @@ async function onCompileCommand(argv: CliOptions): Promise<void> {
networkId: argv.networkId,
optimizerEnabled: argv.shouldOptimize ? 1 : 0,
artifactsDir: argv.artifactsDir,
+ contractsToCompile: generateContractsToCompileSet(argv.contracts),
};
await commands.compileAsync(opts);
}
@@ -43,6 +45,7 @@ async function onMigrateCommand(argv: CliOptions): Promise<void> {
networkId,
optimizerEnabled: argv.shouldOptimize ? 1 : 0,
artifactsDir: argv.artifactsDir,
+ contractsToCompile: generateContractsToCompileSet(argv.contracts),
};
await commands.compileAsync(compilerOpts);
@@ -72,6 +75,7 @@ async function onDeployCommand(argv: CliOptions): Promise<void> {
networkId,
optimizerEnabled: argv.shouldOptimize ? 1 : 0,
artifactsDir: argv.artifactsDir,
+ contractsToCompile: generateContractsToCompileSet(argv.contracts),
};
await commands.compileAsync(compilerOpts);
@@ -90,6 +94,18 @@ async function onDeployCommand(argv: CliOptions): Promise<void> {
await commands.deployAsync(argv.contract, deployerArgs, deployerOpts);
}
/**
+ * Creates a set of contracts to compile.
+ * @param contracts Comma separated list of contracts to compile
+ */
+function generateContractsToCompileSet(contracts: string): Set<string> {
+ const contractsToCompile = new Set();
+ const contractsArray = contracts.split(',');
+ _.forEach(contracts, contractName => {
+ contractsToCompile.add(contractName);
+ });
+ return contractsToCompile;
+}
+/**
* Provides extra required options for deploy command.
* @param yargsInstance yargs instance provided in builder function callback.
*/
@@ -144,6 +160,11 @@ function deployCommandBuilder(yargsInstance: any) {
type: 'string',
description: 'account to use for deploying contracts',
})
+ .option('contracts', {
+ type: 'string',
+ default: DEFAULT_COMPILE_CONTRACTS,
+ description: 'comma separated list of contracts to compile',
+ })
.command('compile', 'compile contracts', identityCommandBuilder, onCompileCommand)
.command(
'migrate',