summaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/update-notifier/node_modules/boxen/node_modules/term-size/node_modules/execa/node_modules/npm-run-path/index.js
blob: 92b8d7dc3d9e36f83a980024367e72970a6d9493 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
'use strict';
var path = require('path');
var pathKey = require('path-key');

module.exports = function (opts) {
	opts = opts || {};

	var prev;
	var pth = path.resolve(opts.cwd || '.');

	var ret = [];

	while (prev !== pth) {
		ret.push(path.join(pth, 'node_modules/.bin'));
		prev = pth;
		pth = path.resolve(pth, '..');
	}

	// ensure the running `node` binary is used
	ret.push(path.dirname(process.execPath));

	return ret.concat(opts.path || process.env[pathKey()]).join(path.delimiter);
};