2023-10-16 13:29:31 -04:00
|
|
|
/**
|
|
|
|
|
* Copyright (c) HashiCorp, Inc.
|
|
|
|
|
* SPDX-License-Identifier: MPL-2.0
|
|
|
|
|
*/
|
|
|
|
|
|
2023-10-10 20:16:34 -04:00
|
|
|
const { isWindows } = require('../helpers/platform.js');
|
|
|
|
|
const shellEnv = require('shell-env');
|
|
|
|
|
|
|
|
|
|
// Utility function to help correctly set the PATH variable on unix systems
|
|
|
|
|
// Inspired by https://github.com/sindresorhus/fix-path
|
|
|
|
|
const fixPath = () => {
|
|
|
|
|
if (isWindows()) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const { PATH } = shellEnv.sync();
|
|
|
|
|
process.env.PATH =
|
|
|
|
|
PATH ||
|
|
|
|
|
[
|
|
|
|
|
'./node_modules/.bin',
|
|
|
|
|
'/.nodebrew/current/bin',
|
|
|
|
|
'/usr/local/bin',
|
|
|
|
|
process.env.PATH,
|
|
|
|
|
].join(':');
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
module.exports = fixPath;
|