Function extractRelevantArgs

  • Trims arguments list to remove all arguments that take place before the script's file name or executable bin name.

    Parameters

    Returns string[]

    extractRelevantArgs({
    rawArgs: [
    'npx',
    'ts-node',
    './my-script.ts',
    'arg1',
    '--arg2',
    ], // typically will be process.argv
    binName: 'my-script', // should be your package.json "bin" property name, can be undefined
    fileName: 'my-script.ts', // should be __filename from the script that will be executed
    });
    // will output ['arg1', '--arg2']