How to use the @boost/common.isEmpty function in @boost/common

To help you get started, we’ve selected a few @boost/common 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 milesj / boost / packages / core / src / ConfigLoader.ts View on Github external
shape({ [singularName]: string().notEmpty() }),
        instance(contract, true),
      ], []));
    });

    const config = optimal(
      this.inheritFromArgs(this.parseAndExtend(configPath), args),
      {
        ...configBlueprint,
        ...pluginsBlueprint,
        debug: bool(),
        extends: array(string()),
        locale: string(),
        output: number(2).between(1, 3, true),
        // shape() requires a non-empty object
        settings: isEmpty(settingsBlueprint) ? object() : shape(settingsBlueprint),
        silent: bool(),
        theme: string('default').notEmpty(),
      },
      {
        file: configPath instanceof Path ? configPath.name() : '',
        name: 'ConfigLoader',
        unknown: true,
      },
    );

    return (config as unknown) as T;
  }
github milesj / boost / packages / core / src / Tool.ts View on Github external
protected loadPlugins(): this {
    if (this.initialized) {
      return this;
    }

    if (isEmpty(this.config)) {
      throw new Error(this.msg('errors:configNotLoaded', { name: 'plugins' }));
    }

    Object.keys(this.pluginTypes).forEach(type => {
      const typeName = type as keyof PluginRegistry;
      const { loader, pluralName } = this.pluginTypes[typeName]!;
      const plugins = loader.loadModules((this.config as any)[pluralName]);

      // Sort plugins by priority
      loader.debug('Sorting by priority');

      plugins.sort((a, b) =>
        instanceOf(a, Plugin) && instanceOf(b, Plugin) ? a.priority - b.priority : 0,
      );

      // Bootstrap each plugin with the tool
github milesj / boost / packages / core / src / Tool.ts View on Github external
protected loadReporters(): this {
    if (this.initialized) {
      return this;
    }

    if (isEmpty(this.config)) {
      throw new Error(this.msg('errors:configNotLoaded', { name: 'reporters' }));
    }

    const reporters = this.plugins.reporter!;
    const { loader } = this.pluginTypes.reporter!;

    // Use a special reporter when in a CI
    // istanbul ignore next
    if (this.isCI() && !env('ENV')) {
      loader.debug('CI environment detected, using %s CI reporter', color.moduleName('boost'));

      this.addPlugin('reporter', new CIReporter());

      // Use default reporter
    } else if (
      reporters.size === 0 ||
github milesj / boost / packages / core / src / ConfigLoader.ts View on Github external
loadConfig(args: Arguments): T {
    if (isEmpty(this.package) || !this.package.name) {
      throw new Error(this.tool.msg('errors:packageJsonNotLoaded'));
    }

    this.debug('Locating configuration');

    const { configBlueprint, settingsBlueprint, root } = this.tool.options;
    const pluginsBlueprint: any = {};
    const configPath =
      this.findConfigFromArg(args.config) ||
      this.findConfigInPackageJSON(this.package) ||
      this.findConfigInLocalFiles(root) ||
      this.findConfigInWorkspaceRoot(root);

    if (!configPath) {
      throw new Error(this.tool.msg('errors:configNotFound'));
    }