How to use the resolve-cwd.silent function in resolve-cwd

To help you get started, we’ve selected a few resolve-cwd 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 gridsome / gridsome / packages / cli / bin / gridsome.js View on Github external
.action((...args) => {
    const create = require('../lib/commands/create')
    return wrapCommand(create)(...args)
  })

program
  .command('info')
  .description('output information about the local environment')
  .action(() => {
    const info = require('../lib/commands/info')
    return wrapCommand(info)()
  })

try {
  const commandsPath = resolveCwd.silent('gridsome/commands')
  const gridsomePath = resolveCwd.silent('gridsome')

  if (commandsPath) {
    require(commandsPath)({ context, program })
  } else if (gridsomePath) {
    require(gridsomePath)({ context, program })
  }
} catch (err) {
  console.log(err)
}

// show a warning if the command does not exist
program.arguments('').action(async command => {
  const { isGridsomeProject, hasYarn } = require('../lib/utils')
  const availableCommands = program.commands.map(cmd => cmd._name)
  const suggestion = didYouMean(command, availableCommands)
github matchai / ts-quick / cli.js View on Github external
#!/usr/bin/env node
"use strict";
// @ts-ignore: No type declaration exists
const resolveCwd = require("resolve-cwd");

const localCLI = resolveCwd.silent("ts-quick/cli");

if (localCLI && localCLI !== __filename) {
  const debug = require("debug")("ts-quick");
  debug("Using local install of ts-quick");
  require(localCLI);
} else {
  require("./cli-main");
}
github sindresorhus / import-local / index.js View on Github external
module.exports = filename => {
	const globalDir = pkgDir.sync(path.dirname(filename));
	const relativePath = path.relative(globalDir, filename);
	const pkg = require(path.join(globalDir, 'package.json'));
	const localFile = resolveCwd.silent(path.join(pkg.name, relativePath));
	const localNodeModules = path.join(process.cwd(), 'node_modules');
	const filenameInLocalNodeModules = !path.relative(localNodeModules, filename).startsWith('..');

	// Use `path.relative()` to detect local package installation,
	// because __filename's case is inconsistent on Windows
	// Can use `===` when targeting Node.js 8
	// See https://github.com/nodejs/node/issues/6624
	return !filenameInLocalNodeModules && localFile && path.relative(localFile, filename) !== '' && require(localFile);
};
github enten / udk / bin / udk.webpack4-cli.js View on Github external
(function() {
	// wrap in IIFE to be able to use return

	const resolveCwd = require("resolve-cwd");
	// Local version replace global one
	const localCLI = resolveCwd.silent("udk/bin/udk");
	if (localCLI && localCLI !== __filename) {
		require(localCLI);
		return;
	}

	require("v8-compile-cache");
	const ErrorHelpers = require("webpack-cli/bin/errorHelpers");

	const NON_COMPILATION_ARGS = [
		"init",
		"migrate",
		/*
		"add",
		"remove",
		"update",
		"make",
github umijs / umi / packages / umi / bin / umi.js View on Github external
#!/usr/bin/env node

const resolveCwd = require('resolve-cwd');

const localCLI = resolveCwd.silent('umi/bin/umi');
if (
  process.argv[2] !== 'ui' &&
  !process.env.USE_GLOBAL_UMI &&
  localCLI &&
  localCLI !== __filename
) {
  const debug = require('debug')('umi');
  debug('Using local install of umi');
  require(localCLI);
} else {
  require('../lib/cli');
}
github avajs / ava / profile.js View on Github external
return arrify(modules).map(name => {
		const modulePath = resolveCwd.silent(name);

		if (modulePath === undefined) {
			throw new Error(`Could not resolve required module '${name}'`);
		}

		return modulePath;
	});
}
github dotansimha / graphql-binding / src / codegen / FlowGenerator.ts View on Github external
} = (isWebpack => {
  if (isWebpack) return require('graphql')

  const resolveCwd = require('resolve-cwd')
  const graphqlPackagePath = resolveCwd.silent('graphql')

  return require(graphqlPackagePath || 'graphql')
})(typeof __non_webpack_require__ !== 'undefined')
github avajs / ava / lib / api.js View on Github external
return arrify(modules).map(name => {
		const modulePath = resolveCwd.silent(name);

		if (modulePath === undefined) {
			throw new Error(`Could not resolve required module '${name}'`);
		}

		return modulePath;
	});
}
github dotansimha / graphql-binding / src / codegen / TypescriptGenerator.ts View on Github external
const resolveCwd = require('resolve-cwd')
const graphqlPackagePath = resolveCwd.silent('graphql')
const {
  isNonNullType,
  isListType,
  GraphQLObjectType,
} = require(graphqlPackagePath || 'graphql')

import {
  GraphQLSchema,
  GraphQLUnionType,
  GraphQLInterfaceType,
  GraphQLInputObjectType,
  GraphQLInputField,
  GraphQLField,
  GraphQLInputType,
  GraphQLOutputType,
  GraphQLWrappingType,
github avajs / ava / lib / api.js View on Github external
return arrify(modules).map(name => {
		const modulePath = resolveCwd.silent(name);

		if (modulePath === undefined) {
			throw new Error(`Could not resolve required module '${name}'`);
		}

		return modulePath;
	});
}

resolve-cwd

Resolve the path of a module like `require.resolve()` but from the current working directory

MIT
Latest version published 6 years ago

Package Health Score

70 / 100
Full package analysis

Popular resolve-cwd functions