How to use npm-run-path - 9 common examples

To help you get started, we’ve selected a few npm-run-path 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 gaoding-inc / ci-task-runner / lib / worker.js View on Github external
return new Promise((resolve, reject) => {

        options = defaultsDeep({}, options, {
            // 子进程继承父进程的环境变量
            env: process.env
        }, {
            // 使用 npm 的 PATH
            env: npmRunPath.env({
                cwd: options.cwd || process.cwd()
            })
        });


        let child;
        let closed;
        let timer = null;

        try {
            child = childProcess.exec(command, options);
        } catch (errors) {
            callback(errors);
        }

        child.stdout.on('data', content => {
github ZhuPeng / mp-githubtrending / cloud-functions / github / node_modules / execa / index.js View on Github external
}

	opts = Object.assign({
		maxBuffer: TEN_MEGABYTES,
		stripEof: true,
		preferLocal: true,
		localDir: parsed.options.cwd || process.cwd(),
		encoding: 'utf8',
		reject: true,
		cleanup: true
	}, parsed.options);

	opts.stdio = stdio(opts);

	if (opts.preferLocal) {
		opts.env = npmRunPath.env(Object.assign({}, opts, {cwd: opts.localDir}));
	}

	if (opts.detached) {
		// #115
		opts.cleanup = false;
	}

	if (process.platform === 'win32' && path.basename(parsed.command) === 'cmd.exe') {
		// #116
		parsed.args.unshift('/q');
	}

	return {
		cmd: parsed.command,
		args: parsed.args,
		opts,
github tidys / CocosCreatorPlugins / packages / res-compress / node_modules / bin-build / node_modules / execa / index.js View on Github external
}

	opts = Object.assign({
		maxBuffer: TEN_MEGABYTES,
		stripEof: true,
		preferLocal: true,
		localDir: parsed.options.cwd || process.cwd(),
		encoding: 'utf8',
		reject: true,
		cleanup: true
	}, parsed.options);

	opts.stdio = stdio(opts);

	if (opts.preferLocal) {
		opts.env = npmRunPath.env(Object.assign({}, opts, {cwd: opts.localDir}));
	}

	return {
		cmd: parsed.command,
		args: parsed.args,
		opts,
		parsed
	};
}
github foo-software / lighthouse-check-action / node_modules / lint-staged / node_modules / execa / index.js View on Github external
const getEnv = ({env: envOption, extendEnv, preferLocal, localDir}) => {
	const env = extendEnv ? {...process.env, ...envOption} : envOption;

	if (preferLocal) {
		return npmRunPath.env({env, cwd: localDir});
	}

	return env;
};
github daviddbarrero / Ionic-4-firebase / node_modules / execa / index.js View on Github external
}

	opts = Object.assign({
		maxBuffer: TEN_MEGABYTES,
		stripEof: true,
		preferLocal: true,
		localDir: parsed.options.cwd || process.cwd(),
		encoding: 'utf8',
		reject: true,
		cleanup: true
	}, parsed.options);

	opts.stdio = stdio(opts);

	if (opts.preferLocal) {
		opts.env = npmRunPath.env(Object.assign({}, opts, {cwd: opts.localDir}));
	}

	return {
		cmd: parsed.command,
		args: parsed.args,
		opts,
		parsed
	};
}
github foo-software / lighthouse-check-action / node_modules / term-size / node_modules / execa / index.js View on Github external
}

	opts = Object.assign({
		maxBuffer: TEN_MEGABYTES,
		stripEof: true,
		preferLocal: true,
		localDir: parsed.options.cwd || process.cwd(),
		encoding: 'utf8',
		reject: true,
		cleanup: true
	}, parsed.options);

	opts.stdio = stdio(opts);

	if (opts.preferLocal) {
		opts.env = npmRunPath.env(Object.assign({}, opts, {cwd: opts.localDir}));
	}

	return {
		cmd: parsed.command,
		args: parsed.args,
		opts,
		parsed
	};
}
github jarden-digital / react-native-pincode / node_modules / execa / index.js View on Github external
}

	opts = Object.assign({
		maxBuffer: TEN_MEGABYTES,
		stripEof: true,
		preferLocal: true,
		localDir: parsed.options.cwd || process.cwd(),
		encoding: 'utf8',
		reject: true,
		cleanup: true
	}, parsed.options);

	opts.stdio = stdio(opts);

	if (opts.preferLocal) {
		opts.env = npmRunPath.env(Object.assign({}, opts, {cwd: opts.localDir}));
	}

	return {
		cmd: parsed.command,
		args: parsed.args,
		opts,
		parsed
	};
}
github gaoding-inc / ci-task-runner / src / run-cmd.js View on Github external
return new Promise((resolve, reject) => {

        options = defaultsDeep({}, options, {
            env: npmRunPath.env({
                cwd: options.cwd || process.cwd(),
                env: defaultsDeep({}, options.env, process.env)
            })
        });

        let timer = null;
        const callback = (errors, data) => {
            clearTimeout(timer);

            if (errors) {
                errors.message = `run "${command}" failed: ${errors.message}`;
                reject(errors);
            } else {
                resolve(data);
            }
        };
github ehmicky / nve / src / path.js View on Github external
export const fixPath = function({
  nodePath,
  spawnOptions,
  spawnOptions: { env, cwd },
}) {
  const npmRunPathOpts = filterObj({ env, cwd, execPath: nodePath }, isDefined)
  const envA = npmRunPath.env(npmRunPathOpts)
  return { ...spawnOptions, env: envA, preferLocal: false }
}

npm-run-path

Get your PATH prepended with locally installed binaries

MIT
Latest version published 2 months ago

Package Health Score

83 / 100
Full package analysis

Popular npm-run-path functions