How to use the @boost/common.requireModule 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 / ModuleLoader.ts View on Github external
modulesToAttempt.some(modName => {
      try {
        importedModule = requireModule(modName);
        moduleName = modName;

        return true;
      } catch (error) {
        if (error.message.startsWith(`Cannot find module '${modName}'`)) {
          this.debug('Failed to import module: %s', error.message);

          return false;
        }

        // Unknown error occurred, abort process
        throw error;
      }
    });
github beemojs / beemo / packages / core / src / routines / CreateConfigRoutine.ts View on Github external
loadConfig(filePath: Path): ConfigObject {
    const config: ConfigObject = requireModule(filePath);

    if (typeof config === 'function') {
      throw new TypeError(this.tool.msg('errors:configNoFunction', { name: filePath.name() }));
    }

    this.options.driver.onLoadModuleConfig.emit([this.context, filePath, config]);

    return config;
  }
github milesj / boost / packages / plugin / src / Loader.ts View on Github external
load(name: ModuleName, options: object = {}): Plugin {
    const { originalPath, resolvedPath } = this.createResolver(name).resolve();

    this.debug('Loading "%s" from %s', name, color.filePath(resolvedPath));

    const factory: Factory = requireModule(resolvedPath);

    if (typeof factory !== 'function') {
      throw new TypeError(
        `Plugin modules must export a default function, found ${typeof factory}.`,
      );
    }

    const plugin = factory(options);

    if (isObject(plugin) && !plugin.name) {
      plugin.name = originalPath.path();
    }

    return plugin;
  }
}
github milesj / boost / packages / debug / src / CrashReporter.ts View on Github external
.forEach(pkgPath => {
        const pkg: { name: string; version: string } = requireModule(
          path.join(pkgPath, 'package.json'),
        );

        this.add(pkg.name, pkg.version);
      });
github beemojs / beemo / packages / core / src / Beemo.ts View on Github external
bootstrapConfigModule() {
    this.debug('Bootstrapping configuration module');

    const { module } = this.config;
    let bootstrap: Function | null = null;

    try {
      if (module === '@local') {
        bootstrap = requireModule(this.getConfigModuleRoot().append('index.js'));
      } else {
        bootstrap = requireModule(module);
      }
    } catch {
      this.debug('No index.js file detected, aborting bootstrap');

      return this;
    }

    const isFunction = typeof bootstrap === 'function';

    this.debug.invariant(isFunction, 'Executing bootstrap function', 'Found', 'Not found');

    if (bootstrap && isFunction) {
      bootstrap(this);
    }

    return this;