Skip to content
This repository has been archived by the owner on Oct 4, 2024. It is now read-only.

Commit

Permalink
fix: warning when passing path on ledger flag
Browse files Browse the repository at this point in the history
  • Loading branch information
gagdiez committed Mar 20, 2024
1 parent 96d0978 commit d7dd7d4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
3 changes: 2 additions & 1 deletion bin/near-cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ yargs // eslint-disable-line
.strict()
.scriptName('near')
.middleware(require('../utils/check-version'))
.middleware(require('../middleware/print-options'))
.middleware(require('../middleware/key-store'))
.middleware(require('../middleware/retro-ledger'))
.middleware(require('../middleware/print-options'))
.command(require('../commands/credentials/add'))
.command(require('../commands/keys/add'))
.command(require('../commands/contract/call'))
Expand Down
16 changes: 16 additions & 0 deletions middleware/retro-ledger.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// In v3.5.0 the argument `useLedgerKey` was a string, in v4.0.0 this was change to a boolean
// Sadly, yargs assumes that --useLedgerKey='anything' is FALSE
// Here we detect if an argument is `useLedgerKey=` and guide the user to the correct format

module.exports = async function ledgerOptions() {
let path = '';

process.argv.forEach(arg => {
path = arg.includes('--useLedgerKey=') ? arg.split('=')[1] : path;
});

if (path != '') {
console.log(`\nPlease use --useLedgerKey --ledgerPath="${path}" instead of --useLedgerKey="${path}"\n`);
process.exit(0);
}
};

0 comments on commit d7dd7d4

Please sign in to comment.