Skip to content

Commit

Permalink
[JS->TS] Migrate wait_seconds.js (#832)
Browse files Browse the repository at this point in the history
* Put parseArgs into the one location where it is used.

* migrate wait_seconds.js (use project standard argument parser)
  • Loading branch information
bh2smith authored Jun 2, 2020
1 parent 32ec390 commit cefc750
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 27 deletions.
11 changes: 10 additions & 1 deletion scripts/invoke_view_function.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
import { parseArgs, getBatchExchange } from "./util";
import { getBatchExchange } from "./util";

function parseArgs(): string[] {
const args = process.argv.slice(4);
const index = args.indexOf("--network");
if (index > -1) {
args.splice(index, 2);
}
return args;
}

module.exports = async (callback: Truffle.ScriptCallback) => {
try {
Expand Down
9 changes: 0 additions & 9 deletions scripts/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,3 @@ export async function addTokens(
// Return token information
return tokens;
}

export function parseArgs(): string[] {
const args = process.argv.slice(4);
const index = args.indexOf("--network");
if (index > -1) {
args.splice(index, 2);
}
return args;
}
17 changes: 0 additions & 17 deletions scripts/wait_seconds.js

This file was deleted.

22 changes: 22 additions & 0 deletions scripts/wait_seconds.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { waitForNSeconds } from "..//test/utilities";
import { factory } from "../src/logging";
const log = factory.getLogger("scripts.wait_seconds");

const argv = require("yargs")
.option("seconds", {
describe: "Number of seconds to wait",
type: "int",
demandOption: true,
})
.help(false)
.version(false).argv;

module.exports = async (callback: Truffle.ScriptCallback) => {
try {
await waitForNSeconds(argv.seconds, web3);
log.info(`waited ${argv.seconds} seconds`);
callback();
} catch (error) {
callback(error);
}
};

0 comments on commit cefc750

Please sign in to comment.