Skip to content

Commit

Permalink
fix(CLI): Fix exit codes around the CLI (#84)
Browse files Browse the repository at this point in the history
  • Loading branch information
nduchak authored Jul 16, 2019
1 parent 1408edc commit c775e1d
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions bin/commands/account.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ async function getAccountNonce (walletPath, options) {
async function createSecureWallet (walletPath, { output, password, overwrite }) {
try {
await generateSecureWallet(walletPath, { output, password, overwrite })
process.exit(1)
process.exit(0)
} catch (e) {
printError(e.message)
}
Expand All @@ -194,7 +194,7 @@ async function createSecureWallet (walletPath, { output, password, overwrite })
async function createSecureWalletByPrivKey (walletPath, priv, { output, password, overwrite }) {
try {
await generateSecureWalletFromPrivKey(walletPath, priv, { output, password, overwrite })
process.exit(1)
process.exit(0)
} catch (e) {
printError(e.message)
}
Expand Down
6 changes: 3 additions & 3 deletions bin/commands/chain.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ async function version (options) {
const status = await client.api.getStatus()
if (json) {
print(status)
process.exit(1)
process.exit(0)
}
printUnderscored(`Difficulty`, status.difficulty)
printUnderscored(`Node version`, status.nodeVersion)
Expand Down Expand Up @@ -65,7 +65,7 @@ async function getNetworkId (options) {
const { networkId } = await client.api.getStatus()
if (json) {
print({ networkId })
process.exit(1)
process.exit(0)
}
printUnderscored(`Network ID`, networkId)
})
Expand All @@ -86,7 +86,7 @@ async function ttl (absoluteTtl, options) {
const height = await client.height()
if (json) {
print({ absoluteTtl, relativeTtl: +height + +absoluteTtl })
process.exit(1)
process.exit(0)
}
printUnderscored('Absolute TTL', absoluteTtl)
printUnderscored('Relative TTL', +height + +absoluteTtl)
Expand Down
2 changes: 1 addition & 1 deletion bin/commands/inspect.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ async function unpackTx (hash, options = {}) {
const { validation, tx, signatures = [], txType: type } = await client.unpackAndVerify(hash)
if (json) {
print({ validation, tx: tx, signatures, type })
process.exit(1)
process.exit(0)
}
printValidation({ validation, tx: { ...tx, signatures: signatures.map(el => el.hash) }, txType: type })
if (!validation.length) print(' ✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓ TX VALID ✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓')
Expand Down
2 changes: 1 addition & 1 deletion bin/commands/transaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ async function verify (txHash, options) {
const { validation, tx, signatures = [], txType: type } = await client.unpackAndVerify(txHash, { networkId })
if (json) {
print({ validation, tx: tx, signatures, type })
process.exit(1)
process.exit(0)
}
printValidation({ validation, tx: { ...tx, signatures: signatures.map(el => el.hash) }, txType: type })
if (!validation.length) print(' ✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓ TX VALID ✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓')
Expand Down
4 changes: 2 additions & 2 deletions bin/utils/account.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export async function askForOverwrite (name, output) {

// Generate `keypair` encrypt it using password and write to `ethereum` keystore file
export async function generateSecureWallet (name, { output = '', password, overwrite }) {
if (!overwrite && !(await askForOverwrite(name, output))) process.exit(0)
if (!overwrite && !(await askForOverwrite(name, output))) process.exit(1)
password = password || await prompt(PROMPT_TYPE.askPassword)
const { secretKey, publicKey } = Crypto.generateKeyPair(true)

Expand All @@ -46,7 +46,7 @@ export async function generateSecureWallet (name, { output = '', password, overw

// Generate `keypair` from `PRIVATE KEY` encrypt it using password and to `ethereum` keystore file
export async function generateSecureWalletFromPrivKey (name, priv, { output = '', password, overwrite }) {
if (!overwrite && !(await askForOverwrite(name, output))) process.exit(0)
if (!overwrite && !(await askForOverwrite(name, output))) process.exit(1)
password = password || await prompt(PROMPT_TYPE.askPassword)

const hexStr = Crypto.hexStringToByte(priv.trim())
Expand Down

0 comments on commit c775e1d

Please sign in to comment.