Dive into secure and efficient coding practices with our curated list of the top 10 examples showcasing 'resolve-cwd' in functional components in JavaScript. Our advanced machine learning engine meticulously scans each line of code, cross-referencing millions of open source libraries to ensure your implementation is not just functional, but also robust and secure. Elevate your React applications to new heights by mastering the art of handling side effects, API calls, and asynchronous operations with confidence and precision.
.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)
#!/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");
}
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);
};
(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",
function getLocalInstallation () {
const local = resolveCwd('testcafe/lib/cli');
if (local && local !== __filename) {
log.write('Using locally installed version of TestCafe.');
return local;
}
return '';
}
async function requireFFMPEGModuleFromCwd () {
try {
const ffmpegModulePath = resolveCwd(FFMPEG_MODULE_NAME);
return require(ffmpegModulePath).path;
}
catch (e) {
return '';
}
}
#!/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');
}
return arrify(modules).map(name => {
const modulePath = resolveCwd.silent(name);
if (modulePath === undefined) {
throw new Error(`Could not resolve required module '${name}'`);
}
return modulePath;
});
}
} = (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')
return arrify(modules).map(name => {
const modulePath = resolveCwd.silent(name);
if (modulePath === undefined) {
throw new Error(`Could not resolve required module '${name}'`);
}
return modulePath;
});
}