Skip to content

Commit e0bca0a

Browse files
authored
Merge pull request #189 from aminya/path [skip ci]
2 parents 662daca + 307b917 commit e0bca0a

File tree

7 files changed

+59
-44
lines changed

7 files changed

+59
-44
lines changed

dist/actions/setup-cpp.js

Lines changed: 12 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/actions/setup-cpp.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/legacy/setup-cpp.js

Lines changed: 17 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/legacy/setup-cpp.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/modern/setup-cpp.js

Lines changed: 12 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/modern/setup-cpp.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/utils/env/addEnv.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,27 @@ function escapeString(valGiven: string, shouldEscapeSpace: boolean = false) {
6161
return escapeQuote(spaceEscaped, '"', "\\")
6262
}
6363

64+
const ignoredPaths = [/\/usr\/bin\/?/, /\/usr\/local\/bin\/?/]
65+
66+
/** Skip adding /usr/bin to PATH if it is already there */
67+
function isIgnoredPath(path: string) {
68+
if (ignoredPaths.some((checkedPath) => checkedPath.test(path))) {
69+
const paths = process.env.PATH?.split(delimiter) ?? []
70+
return paths.includes(path)
71+
}
72+
return false
73+
}
74+
6475
/**
6576
* Add a path to the PATH environment variable.
6677
*
6778
* This function is cross-platforms and works in all the local or CI systems.
6879
*/
6980
export async function addPath(path: string) {
81+
if (isIgnoredPath(path)) {
82+
return
83+
}
84+
7085
process.env.PATH = `${path}${delimiter}${process.env.PATH}`
7186
try {
7287
if (GITHUB_ACTIONS) {

0 commit comments

Comments
 (0)