Skip to content

Commit 5359cc6

Browse files
committed
fix(@embark/cmd-controller): exit build if afterDeploy is not array
Before, `embark build` would wait at the end if there was an afterDeploy, because there was no way with the old string and array syntax to know when the commands were done. Now, with the function syntax, we can wait for the end. This way, we can exit the build at the end if it is a function afterDeploy. Otherwise, we show a message saying that they should update
1 parent f502650 commit 5359cc6

File tree

4 files changed

+14
-15
lines changed

4 files changed

+14
-15
lines changed

dapps/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
**/config/livenet/password
44
**/config/production/password
55
**/embarkArtifacts
6+
**/build

dapps/tests/contracts/contracts.json renamed to dapps/tests/contracts/contracts.js

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{
1+
module.exports = {
22
"default": {
33
"versions": {
44
"solc": "0.4.26"
@@ -18,9 +18,7 @@
1818
},
1919
"SimpleStorage": {
2020
"fromIndex": 0,
21-
"args": [
22-
100
23-
]
21+
"args": [100]
2422
},
2523
"AnotherStorage": {
2624
"args": [
@@ -33,9 +31,7 @@
3331
"args": [1000]
3432
},
3533
"Test": {
36-
"onDeploy": [
37-
"Test.methods.changeAddress('$MyToken')"
38-
]
34+
"onDeploy": ["Test.methods.changeAddress('$MyToken')"]
3935
},
4036
"MyToken": {
4137
"instanceOf": "Token"
@@ -64,10 +60,11 @@
6460
]
6561
}
6662
},
67-
"afterDeploy": [
68-
"Test.methods.changeAddress('$MyToken')",
69-
"web3.eth.getAccounts((err, accounts) => Test.methods.changeAddress(accounts[0]))"
70-
]
63+
afterDeploy: async ({contracts, web3}) => {
64+
await contracts.Test.methods.changeAddress(contracts.MyToken.options.address).send();
65+
const accounts = await web3.eth.getAccounts();
66+
await contracts.Test.methods.changeAddress(accounts[0]).send();
67+
}
7168
},
7269
"development": {
7370
"deploy": {
@@ -77,4 +74,4 @@
7774
}
7875
}
7976
}
80-
}
77+
};

dapps/tests/contracts/embark.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"app": {},
66
"buildDir": "build/",
77
"config": {
8-
"contracts": "contracts.json",
8+
"contracts": "contracts.js",
99
"storage": false,
1010
"communication": false,
1111
"webserver": false,

packages/embark/src/cmd/cmd_controller.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,11 +340,12 @@ class EmbarkController {
340340
if (err) {
341341
engine.logger.error(err.message || err);
342342
}
343-
// TODO: this should be moved out and determined somewhere else
344-
if (!engine.config.contractsConfig.afterDeploy || !engine.config.contractsConfig.afterDeploy.length) {
343+
if (!engine.config.contractsConfig.afterDeploy || !engine.config.contractsConfig.afterDeploy.length || !Array.isArray(engine.config.contractsConfig.afterDeploy)) {
345344
process.exit(err ? 1 : 0);
346345
}
347346
engine.logger.info(__('Waiting for after deploy to finish...'));
347+
engine.logger.info(__('Embark would exit automatically if you were using the function syntax in your afterDeploy instead of the Array syntax.'));
348+
engine.logger.info(__('Find more information here: %s', 'https://framework.embarklabs.io/docs/contracts_configuration.html#afterDeploy-hook'.underline));
348349
engine.logger.info(__('You can exit with CTRL+C when after deploy completes'));
349350
});
350351
}

0 commit comments

Comments
 (0)