How to use @expo/commander - 5 common examples

To help you get started, we’ve selected a few @expo/commander examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github expo / expo / tools / expotools / src / expotools-cli.ts View on Github external
async function runAsync() {
  try {
    program.name('expotools');
    program.version(require('../package.json').version);

    // Load each module found in ./commands by 'registering' it with our commander instance
    glob
      .sync('commands/*.js', {
        cwd: __dirname,
      })
      .forEach(file => {
        const commandModule = require(`./${file}`);
        if (typeof commandModule === 'function') {
          commandModule(program);
        } else if (typeof commandModule.default === 'function') {
          commandModule.default(program);
        } else {
          console.error(`"${file}.js" is not a properly formatted command.`);
        }
github expo / expo / tools / expotools / src / expotools-cli.ts View on Github external
async function runAsync() {
  try {
    program.name('expotools');
    program.version(require('../package.json').version);

    // Load each module found in ./commands by 'registering' it with our commander instance
    glob
      .sync('commands/*.js', {
        cwd: __dirname,
      })
      .forEach(file => {
        const commandModule = require(`./${file}`);
        if (typeof commandModule === 'function') {
          commandModule(program);
        } else if (typeof commandModule.default === 'function') {
          commandModule.default(program);
        } else {
          console.error(`"${file}.js" is not a properly formatted command.`);
        }
      });
github expo / expo / tools / expotools / src / expotools-cli.ts View on Github external
program.parse(process.argv);

    const subCommandName = process.argv[2];
    const subCommand =
      subCommandName &&
      program.commands.find(({ _name, _aliases }) => {
        return _name === subCommandName || (_aliases && _aliases.includes(subCommandName));
      });

    if (!subCommand) {
      subCommandName &&
        console.log(
          chalk.bold.green(subCommandName),
          chalk.red('is not an expotools command. See below for the full list of commands.\n')
        );
      program.help();
    }
  } catch (e) {
    console.error(chalk.red(e));
    throw e;
  }
}
github expo / expo / tools / expotools / src / expotools-cli.ts View on Github external
glob
      .sync('commands/*.js', {
        cwd: __dirname,
      })
      .forEach(file => {
        const commandModule = require(`./${file}`);
        if (typeof commandModule === 'function') {
          commandModule(program);
        } else if (typeof commandModule.default === 'function') {
          commandModule.default(program);
        } else {
          console.error(`"${file}.js" is not a properly formatted command.`);
        }
      });

    program.parse(process.argv);

    const subCommandName = process.argv[2];
    const subCommand =
      subCommandName &&
      program.commands.find(({ _name, _aliases }) => {
        return _name === subCommandName || (_aliases && _aliases.includes(subCommandName));
      });

    if (!subCommand) {
      subCommandName &&
        console.log(
          chalk.bold.green(subCommandName),
          chalk.red('is not an expotools command. See below for the full list of commands.\n')
        );
      program.help();
    }
github expo / expo / tools / expotools / src / expotools-cli.ts View on Github external
const commandModule = require(`./${file}`);
        if (typeof commandModule === 'function') {
          commandModule(program);
        } else if (typeof commandModule.default === 'function') {
          commandModule.default(program);
        } else {
          console.error(`"${file}.js" is not a properly formatted command.`);
        }
      });

    program.parse(process.argv);

    const subCommandName = process.argv[2];
    const subCommand =
      subCommandName &&
      program.commands.find(({ _name, _aliases }) => {
        return _name === subCommandName || (_aliases && _aliases.includes(subCommandName));
      });

    if (!subCommand) {
      subCommandName &&
        console.log(
          chalk.bold.green(subCommandName),
          chalk.red('is not an expotools command. See below for the full list of commands.\n')
        );
      program.help();
    }
  } catch (e) {
    console.error(chalk.red(e));
    throw e;
  }
}

@expo/commander

the complete solution for node.js command-line programs

MIT
Latest version published 4 years ago

Package Health Score

66 / 100
Full package analysis