From 0439313a10f9de79d8054341c331ccbbe2bdceb6 Mon Sep 17 00:00:00 2001 From: Mike Seese Date: Sat, 9 Jan 2021 14:05:03 -0800 Subject: [PATCH] ensure yargs `option` options are properly processed --- CONTRIBUTING.md | 12 +++++++++++- scripts/create.ts | 11 ++++++----- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a1bdb13cd2..a0ea0e21ae 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -57,9 +57,19 @@ Runs all tests: - `npm test` (or the shorthand, `npm t`) +## To create a new chain/flavor + +- `npm run create -- --location chains` + +**NOTE:** The `--` between `npm run create` and `` is required to properly use this script. + +This will create a new folder at `src/chains/` where `` should be the flavor name (e.g. `ethereum`), which you then can [create packages under](#to-create-a-new-package). + ## To create a new package -- `npm run create --location [--folder ]` +- `npm run create -- --location [--folder ]` + +**NOTE:** The `--` between `npm run create` and `` is required to properly use this script. This will create a new package with Ganache defaults at `src//`. diff --git a/scripts/create.ts b/scripts/create.ts index a2ba20bc0a..b0a0891522 100644 --- a/scripts/create.ts +++ b/scripts/create.ts @@ -31,7 +31,7 @@ const chainLocations = getDirectories(join(__dirname, "../src/chains")).map( locations = locations.concat(chainLocations); const argv = yargs .command( - `$0 --location [--folder]`, + `$0 [options]`, `Create a new package in the given location with the provided name.`, yargs => { return yargs @@ -40,19 +40,22 @@ const argv = yargs chalk`{bold Usage}\n {bold $} {dim <}name{dim >} {dim --}location {dim <}location{dim >} {dim [--folder ]}` ) .positional("name", { - describe: ` The name for the new package.`, + describe: `The name for the new package.`, type: "string", demandOption: true }) .option("location", { alias: "l", describe: `The location for the new package.`, + type: "string", choices: locations, demandOption: true }) .option("folder", { alias: "f", - describe: chalk`Optional override for the folder name for the package instead of using {dim <}name{dim >}.` + describe: chalk`Optional override for the folder name for the package instead of using {dim <}name{dim >}.`, + type: "string", + demandOption: false }); } ) @@ -60,8 +63,6 @@ const argv = yargs .version(false) .help(false) .updateStrings({ - "Positionals:": chalk.bold("Options"), - "Options:": ` `, "Not enough non-option arguments: got %s, need at least %s": { one: chalk`{red {bold ERROR! Not enough non-option arguments:}\n got %s, need at least %s}`, other: chalk`{red {bold ERROR! Not enough non-option arguments:}\n got %s, need at least %s}`