How to use the flex-dev-utils.logger.error function in flex-dev-utils

To help you get started, we’ve selected a few flex-dev-utils 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 twilio / flex-plugin-builder / packages / flex-plugin-scripts / src / index.ts View on Github external
let scripts = files
    .filter((f) => {
      const ext = f.split('.').pop();

      return ext === 'js' || ext === 'ts';
    })
    .map((f) => f.split('.')[0])
    .filter((f) => f !== 'run');
  scripts = [...new Set(scripts)];

  const scriptIndex = argv.findIndex((x) => scripts.includes(x));
  const script = scriptIndex !== -1 && argv[scriptIndex];

  if (!script) {
    const options = logger.colors.blue(scripts.join(', '));
    logger.error(`Unknown script '${script}'; please choose from one of: ${options}.`);
    return process.exit(1);
  }

  // Print help doc and quit
  if (argv.includes('--help') && script) {
    const docPath = join(dir, '../docs', script) + '.md';
    if (!existsSync(docPath)) {
      logger.warning(`No documentation was found for ${script}`);
      return process.exit(1);
    }

    markedRender(docPath);
    return process.exit(0);
  }

  const nodeArgs = scriptIndex > 0 ? argv.slice(0, scriptIndex) : [];
github twilio / flex-plugin-builder / packages / flex-plugin-scripts / src / index.ts View on Github external
let scripts = files
    .filter((f) => {
      const ext = f.split('.').pop();

      return ext === 'js' || ext === 'ts';
    })
    .map((f) => f.split('.')[0])
    .filter((f) => f !== 'run');
  scripts = [...new Set(scripts)];

  const scriptIndex = argv.findIndex((x) => scripts.includes(x));
  const script = scriptIndex !== -1 && argv[scriptIndex];

  if (!script) {
    const options = logger.colors.blue(scripts.join(', '));
    logger.error(`Unknown script '${script}'; please choose from one of: ${options}.`);
    return process.exit(1);
  }

  // Print help doc and quit
  if (argv.includes('--help') && script) {
    const docPath = join(dir, '../docs', script) + '.md';
    if (!existsSync(docPath)) {
      logger.warning(`No documentation was found for ${script}`);
      return process.exit(1);
    }

    markedRender(docPath);
    return process.exit(0);
  }

  const nodeArgs = scriptIndex > 0 ? argv.slice(0, scriptIndex) : [];
github twilio / flex-plugin-builder / packages / create-flex-plugin / src / lib / create-flex-plugin.ts View on Github external
if (fs.existsSync(config.targetDirectory)) {
    throw new FlexPluginError(singleLineString(
      `Path ${logger.coloredStrings.link(config.targetDirectory)} already exists;`,
      'please remove it and try again.',
    ));
  }

  // Setup the directories
  if (!await _scaffold(config)) {
    throw new FlexPluginError('Failed to scaffold project');
  }

  // Install NPM dependencies
  if (config.install) {
    if (!await _install(config)) {
      logger.error('Failed to install dependencies. Please run `npm install` manually.');
      config.install = false;
    }
  }

  finalMessage(config);
};
github twilio / flex-plugin-builder / packages / flex-plugin-scripts / src / utils / run.ts View on Github external
.catch((e) => {
        if (e instanceof FlexPluginError) {
          e.print();
          if (process.env.DEBUG) {
            e.details();
          }
        } else {
          logger.error(e);
        }

        return process.exit(1);
      });
  }
github twilio / flex-plugin-builder / packages / flex-plugin-scripts / src / utils / spawn.ts View on Github external
const spawn = (processArgs: string[]): number => {
  const child = spawnSync('node', processArgs, { stdio: 'inherit' });

  if (child.signal) {
    if (child.signal === 'SIGKILL') {
      logger.error([
        'The build failed because the process exited too early. ',
        'This probably means the system ran out of memory or someone called ',
        '`kill -9` on the process.',
      ].join('\n'));
    } else if (child.signal === 'SIGTERM') {
      logger.warning([
        'The build failed because the process exited too early. ',
        'Someone might have called  `kill` or `killall`, or the system could ',
        'be shutting down.',
       ].join('\n'));
    }

    process.exit(1);
  }

  return child.status || 0;
github twilio / flex-plugin-builder / packages / flex-plugin-scripts / src / prints / expectedDependencyNotFound.ts View on Github external
export default (packageName: string) => {
  const nameColor = logger.coloredStrings.name;
  const flexUIName = nameColor('@twilio/flex-ui');

  logger.newline();
  logger.error('An expected package was not found.');
  logger.newline();

  logger.info(`Expected package ${nameColor(packageName)} was not found in ${flexUIName}.`);
  logger.newline();

  instructionToReinstall();
};
github twilio / flex-plugin-builder / packages / flex-plugin-scripts / src / prints / packagesVersions.ts View on Github external
export default (foundPackages: PackageDetail[], notFoundPackages: PackageDetail[]) => {
  const headline = logger.coloredStrings.headline;

  logger.info('Your plugin has the following packages installed:');
  logger.newline();
  foundPackages
    .forEach((detail) => {
      logger.info(`\t ${headline(`"${detail.name}": "${detail.package.version}"`)}`);
    });

  if (notFoundPackages.length) {
    logger.newline();
    logger.error('However, some required packages were not found:');
    logger.newline();
    notFoundPackages
      .forEach((detail) => {
        logger.info(`\t ${headline(`"${detail.name}"`)}`);
      });
    logger.newline();

    instructionToReinstall();
  }
};