Skip to content

Commit 9d12750

Browse files
committed
fix: always add guards for sourcing rc files
1 parent c9007c8 commit 9d12750

File tree

5 files changed

+10
-9
lines changed

5 files changed

+10
-9
lines changed

dist/legacy/setup-cpp.js

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.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.mjs

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

dist/modern/setup-cpp.mjs.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.

packages/envosman/src/rc-file.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,17 @@ import { pathExists } from "path-exists"
77
import { untildifyUser } from "untildify-user"
88
const { appendFile, readFile, writeFile } = promises
99

10+
export const defaultGuard = "envosman"
1011
export const defaultRcPath = untildifyUser("~/.envosmanrc")
1112

1213
/**
1314
* Options for adding an rc file
1415
*/
1516
export type RcOptions = {
16-
/** The path to the RC file that the env variables should be added to. */
17+
/** The path to the RC file that the env variables should be added to. (Default to "~/.envosmanrc") */
1718
rcPath: string
1819

19-
/** Provide a name (your tool) to add a variable guard for sourcing your rc file */
20+
/** Provide a name (your tool) to add a variable guard for sourcing your rc file (Default to "envosman") */
2021
guard?: string
2122
}
2223

@@ -31,9 +32,9 @@ async function sourceRCInRc_(options: RcOptions) {
3132
return
3233
}
3334

34-
const sourceRcString = options.guard === undefined
35-
? `\nsource "${rcPath}"\n`
36-
: `\n# ${options.guard}\nif [[ "$SOURCE_${options.guard.toUpperCase()}RC" != 0 && -f "${rcPath}" ]]; then source "${rcPath}"; fi\n`
35+
const guard = options.guard ?? defaultGuard
36+
const sourceRcString =
37+
`\n# ${guard}\nif [[ "$SOURCE_${guard.toUpperCase()}RC" != 0 && -f "${rcPath}" ]]; then source "${rcPath}"; fi\n`
3738

3839
try {
3940
await Promise.all([

0 commit comments

Comments
 (0)