How to use the @boost/common.PathResolver 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 / plugin / src / Loader.ts View on Github external
createResolver(name: ModuleName): PathResolver {
    const resolver = new PathResolver();
    const { singularName: typeName, projectName } = this.manager;
    const moduleName = name.toLowerCase();
    const modulePattern = MODULE_PART_PATTERN.source;
    const isNotToolOrType = !moduleName.includes(projectName) && !moduleName.includes(typeName);

    this.debug('Resolving possible %s modules', color.pluginName(typeName));

    // @scope/tool-plugin-name
    if (
      moduleName.match(
        new RegExp(`^@${modulePattern}/${projectName}-${typeName}-${modulePattern}$`, 'u'),
      )
    ) {
      this.debug('Found an explicit module with custom scope: %s', color.moduleName(moduleName));

      resolver.lookupNodeModule(moduleName);
github beemojs / beemo / packages / core / src / routines / CreateConfigRoutine.ts View on Github external
getConfigPath(forceLocal: boolean = false): Path | null {
    const { cwd, workspaceRoot } = this.context;
    const moduleName = this.tool.config.module;
    const { name } = this.options.driver;
    const configName = this.getConfigName(name);
    const isLocal = moduleName === '@local' || forceLocal;
    const resolver = new PathResolver();

    // Allow for local development
    if (isLocal) {
      resolver
        .lookupFilePath(`lib/configs/${configName}.js`, workspaceRoot || cwd)
        .lookupFilePath(`configs/${configName}.js`, workspaceRoot || cwd);
    } else {
      resolver
        .lookupNodeModule(`${moduleName}/lib/configs/${configName}`)
        .lookupNodeModule(`${moduleName}/configs/${configName}`);
    }

    let configPath = null;

    try {
      configPath = resolver.resolvePath();
github beemojs / beemo / packages / core / src / routines / RunScriptRoutine.ts View on Github external
loadScriptFromModule(context: ScriptContext, script: Script | null): Script | null {
    if (script) {
      return script;
    }

    this.debug('Attempting to load script from configuration module or node module');

    const moduleName = this.tool.config.module;
    const fileName = upperFirst(camelCase(context.scriptName));
    const resolver = new PathResolver();

    if (moduleName === '@local') {
      resolver
        .lookupFilePath(`lib/scripts/${fileName}.js`, context.moduleRoot)
        .lookupFilePath(`scripts/${fileName}.js`, context.moduleRoot);
    } else {
      resolver
        .lookupNodeModule(`${moduleName}/lib/scripts/${fileName}`)
        .lookupNodeModule(`${moduleName}/scripts/${fileName}`)
        .lookupNodeModule(formatModuleName('beemo', 'script', context.scriptName, true))
        .lookupNodeModule(formatModuleName('beemo', 'script', context.scriptName));
    }

    try {
      const { originalPath, resolvedPath } = resolver.resolve();