function _run()

in common/scripts/install-run-rush.js [60:84]


function _run() {
    const [nodePath /* Ex: /bin/node */, scriptPath /* /repo/common/scripts/install-run-rush.js */, ...packageBinArgs /* [build, --to, myproject] */] = process.argv;
    // Detect if this script was directly invoked, or if the install-run-rushx script was invokved to select the
    // appropriate binary inside the rush package to run
    const scriptName = path.basename(scriptPath);
    const bin = scriptName.toLowerCase() === 'install-run-rushx.js' ? 'rushx' : 'rush';
    if (!nodePath || !scriptPath) {
        throw new Error('Unexpected exception: could not detect node path or script path');
    }
    if (process.argv.length < 3) {
        console.log(`Usage: ${scriptName} <command> [args...]`);
        if (scriptName === 'install-run-rush.js') {
            console.log(`Example: ${scriptName} build --to myproject`);
        }
        else {
            console.log(`Example: ${scriptName} custom-command`);
        }
        process.exit(1);
    }
    install_run_1.runWithErrorAndStatusCode(() => {
        const version = _getRushVersion();
        console.log(`The rush.json configuration requests Rush version ${version}`);
        return install_run_1.installAndRun(PACKAGE_NAME, version, bin, packageBinArgs);
    });
}