From aa30b395251cb5c59e729ad828d4506541ecaeed Mon Sep 17 00:00:00 2001 From: Jeeyong Um Date: Fri, 10 Mar 2023 02:16:11 +0900 Subject: [PATCH] Fix inaccessible yargs instance error (#5531) --- packages/typegen/src/extractChain.ts | 3 ++- packages/typegen/src/fromChain.ts | 3 ++- packages/typegen/src/fromDefs.ts | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/typegen/src/extractChain.ts b/packages/typegen/src/extractChain.ts index 8ed2586b0d..6120fbe81a 100644 --- a/packages/typegen/src/extractChain.ts +++ b/packages/typegen/src/extractChain.ts @@ -6,6 +6,7 @@ import process from 'process'; import yargs from 'yargs'; +import { hideBin } from 'yargs/helpers'; import { ApiPromise, WsProvider } from '@polkadot/api'; @@ -29,7 +30,7 @@ type ArgV = { ws: string }; export function main (): void { // retrieve and parse arguments - we do this globally, since this is a single command - const { ws } = yargs + const { ws } = yargs(hideBin(process.argv)) .usage('Usage: [options]') .wrap(120) .strict() diff --git a/packages/typegen/src/fromChain.ts b/packages/typegen/src/fromChain.ts index 4401fc1312..1f959a3ee1 100644 --- a/packages/typegen/src/fromChain.ts +++ b/packages/typegen/src/fromChain.ts @@ -6,6 +6,7 @@ import type { HexString } from '@polkadot/util/types'; import fs from 'fs'; import path from 'path'; import yargs from 'yargs'; +import { hideBin } from 'yargs/helpers'; import { Definitions, DefinitionsTypes } from '@polkadot/types/types'; import { formatNumber, isHex } from '@polkadot/util'; @@ -71,7 +72,7 @@ async function generate (metaHex: HexString, pkg: string | undefined, output: st type ArgV = { endpoint: string; output: string; package?: string; strict?: boolean }; async function mainPromise (): Promise { - const { endpoint, output, package: pkg, strict: isStrict } = yargs.strict().options({ + const { endpoint, output, package: pkg, strict: isStrict } = yargs(hideBin(process.argv)).strict().options({ endpoint: { description: 'The endpoint to connect to (e.g. wss://kusama-rpc.polkadot.io) or relative path to a file containing the JSON output of an RPC state_getMetadata call', required: true, diff --git a/packages/typegen/src/fromDefs.ts b/packages/typegen/src/fromDefs.ts index 0ad20f1858..02abe2b4ca 100644 --- a/packages/typegen/src/fromDefs.ts +++ b/packages/typegen/src/fromDefs.ts @@ -6,6 +6,7 @@ import type { HexString } from '@polkadot/util/types'; import fs from 'fs'; import path from 'path'; import yargs from 'yargs'; +import { hideBin } from 'yargs/helpers'; import * as substrateDefs from '@polkadot/types/interfaces/definitions'; import { isHex } from '@polkadot/util'; @@ -18,7 +19,7 @@ import { assertDir, assertFile, getMetadataViaWs } from './util/index.js'; type ArgV = { input: string; package: string; endpoint?: string; }; async function mainPromise (): Promise { - const { endpoint, input, package: pkg } = yargs.strict().options({ + const { endpoint, input, package: pkg } = yargs(hideBin(process.argv)).strict().options({ endpoint: { description: 'The endpoint to connect to (e.g. wss://kusama-rpc.polkadot.io) or relative path to a file containing the JSON output of an RPC state_getMetadata call', type: 'string'