How to use resolve-global - 5 common examples

To help you get started, we’ve selected a few resolve-global 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 Raagh / angular-karma_test-explorer / src / core / angular / angular-process-configurator.ts View on Github external
public createProcessCommandAndArguments(
    projectName: string,
    baseKarmaConfigFilePath: string,
    workspaceRootPath: string,
    angularProcessCommand: string,
    angularProcessArguments: string[]
  ) {
    const path = require("path");
    const resolveGlobal = require("resolve-global");
    const isAngularInstalledGlobally = resolveGlobal.silent("@angular/cli") != null;
    const isAngularInstalledLocally = this.fileHelper.doesFileExists(path.join(workspaceRootPath, "node_modules", "@angular", "cli", "bin", "ng"));

    if (angularProcessCommand) {
      return {
        cliCommand: angularProcessCommand,
        cliArgs: [projectName, `--karma-config="${baseKarmaConfigFilePath}"`, "--progress=false", ...angularProcessArguments],
      };
    }

    const commonArgs = ["test", projectName, `--karma-config="${baseKarmaConfigFilePath}"`, "--progress=false", ...angularProcessArguments];
    let cliCommand: string = "";
    let cliArgs: string[] = [];

    if (isAngularInstalledGlobally) {
      cliArgs = commonArgs;
      cliCommand = "ng";
github conventional-changelog / commitlint / @commitlint / cli / src / cli.js View on Github external
function loadFormatter(config, flags) {
	const moduleName = flags.format || config.formatter || '@commitlint/format';
	const modulePath =
		resolveFrom.silent(__dirname, moduleName) ||
		resolveFrom.silent(flags.cwd, moduleName) ||
		resolveGlobal.silent(moduleName);

	if (modulePath) {
		const moduleInstance = require(modulePath);

		if (isFunction(moduleInstance.default)) {
			return moduleInstance.default;
		}

		return moduleInstance;
	}

	throw new Error(`Using format ${moduleName}, but cannot find the module.`);
}
github conventional-changelog / commitlint / @commitlint / cli / src / cli.js View on Github external
function loadFormatter(config, flags) {
	const moduleName = flags.format || config.formatter || '@commitlint/format';
	const modulePath =
		resolveFrom.silent(__dirname, moduleName) ||
		resolveFrom.silent(flags.cwd, moduleName) ||
		resolveGlobal.silent(moduleName);

	if (modulePath) {
		const moduleInstance = require(modulePath);

		if (isFunction(moduleInstance.default)) {
			return moduleInstance.default;
		}

		return moduleInstance;
	}

	throw new Error(`Using format ${moduleName}, but cannot find the module.`);
}
github dalcib / parcel-plugin-react-native-web / lib / utils.js View on Github external
function getParcelPath() {
  const globalPath = resolveGlobal.silent('parcel-bundler')
  return globalPath ? globalPath.substr(0, globalPath.length - 8) : 'parcel-bundler'
}
exports.getParcelPath = getParcelPath
github walrusjs / walrus / packages / walrus-plugin-commitlint / src / utils / index.ts View on Github external
export function loadFormatter(config, flags) {
  const moduleName = flags.format || config.formatter || '@commitlint/format';
  const modulePath =
    resolveFrom.silent(__dirname, moduleName) ||
    resolveFrom.silent(flags.cwd, moduleName) ||
    resolveGlobal.silent(moduleName);

  if (modulePath) {
    const moduleInstance = require(modulePath);

    if (_.isFunction(moduleInstance.default)) {
      return moduleInstance.default;
    }

    return moduleInstance;
  }

  throw new Error(`Using format ${moduleName}, but cannot find the module.`);
}

resolve-global

Resolve the path of a globally installed module

MIT
Latest version published 5 months ago

Package Health Score

73 / 100
Full package analysis

Popular resolve-global functions