source: frontend/node_modules/npm-run-path/index.js

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 11 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 1013 bytes
Line 
1'use strict';
2const path = require('path');
3const pathKey = require('path-key');
4
5const npmRunPath = options => {
6 options = {
7 cwd: process.cwd(),
8 path: process.env[pathKey()],
9 execPath: process.execPath,
10 ...options
11 };
12
13 let previous;
14 let cwdPath = path.resolve(options.cwd);
15 const result = [];
16
17 while (previous !== cwdPath) {
18 result.push(path.join(cwdPath, 'node_modules/.bin'));
19 previous = cwdPath;
20 cwdPath = path.resolve(cwdPath, '..');
21 }
22
23 // Ensure the running `node` binary is used
24 const execPathDir = path.resolve(options.cwd, options.execPath, '..');
25 result.push(execPathDir);
26
27 return result.concat(options.path).join(path.delimiter);
28};
29
30module.exports = npmRunPath;
31// TODO: Remove this for the next major release
32module.exports.default = npmRunPath;
33
34module.exports.env = options => {
35 options = {
36 env: process.env,
37 ...options
38 };
39
40 const env = {...options.env};
41 const path = pathKey({env});
42
43 options.path = env[path];
44 env[path] = module.exports(options);
45
46 return env;
47};
Note: See TracBrowser for help on using the repository browser.