Skip to content

Commit efbc01e

Browse files
committed
fix!: rename addEnv options to be simpler
1 parent fce9cac commit efbc01e

File tree

12 files changed

+44
-44
lines changed

12 files changed

+44
-44
lines changed

dist/actions/hdi.647acde1.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/actions/setup-cpp.js

Lines changed: 8 additions & 8 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/hdi.619de66c.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: 8 additions & 8 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/hdi.647acde1.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: 8 additions & 8 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.

packages/os-env/src/add-env.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ const { appendFile } = promises
99

1010
export type AddEnvOptions = {
1111
/** If true, the value will be escaped with quotes and spaces will be escaped with backslash */
12-
shouldEscapeSpace: boolean
13-
/** If true, the variable will be only added if it is not defined */
14-
shouldAddOnlyIfNotDefined: boolean
12+
escapeSpace: boolean
13+
/** If false, the variable will be only added if it is not already defined (Default to true) */
14+
overwrite: boolean
1515
/**
1616
* The path to the RC file that the env variables should be added to.
1717
*/
@@ -31,17 +31,17 @@ export async function addEnv(
3131
givenOptions: Partial<AddEnvOptions> = {},
3232
) {
3333
const options = {
34-
shouldEscapeSpace: false,
35-
shouldAddOnlyIfNotDefined: false,
34+
escapeSpace: false,
35+
overwrite: true,
3636
rcPath: defaultRcPath,
3737
...givenOptions,
3838
}
3939

40-
const val = escapeString(valGiven ?? "", options.shouldEscapeSpace)
40+
const val = escapeString(valGiven ?? "", options.escapeSpace)
4141
try {
4242
if (GITHUB_ACTIONS) {
4343
try {
44-
if (options.shouldAddOnlyIfNotDefined) {
44+
if (!options.overwrite) {
4545
if (process.env[name] !== undefined) {
4646
info(`Environment variable ${name} is already defined. Skipping.`)
4747
return
@@ -64,7 +64,7 @@ async function addEnvSystem(name: string, valGiven: string | undefined, options:
6464
const val = valGiven ?? ""
6565
switch (process.platform) {
6666
case "win32": {
67-
if (options.shouldAddOnlyIfNotDefined) {
67+
if (!options.overwrite) {
6868
if (process.env[name] !== undefined) {
6969
info(`Environment variable ${name} is already defined. Skipping.`)
7070
return
@@ -78,7 +78,7 @@ async function addEnvSystem(name: string, valGiven: string | undefined, options:
7878
case "linux":
7979
case "darwin": {
8080
await sourceRCInRc(options)
81-
if (options.shouldAddOnlyIfNotDefined) {
81+
if (!options.overwrite) {
8282
await appendFile(options.rcPath, `\nif [ -z "\${${name}}" ]; then export ${name}="${val}"; fi\n`)
8383
info(`if not defined ${name} then ${name}="${val}" was added to "${options.rcPath}`)
8484
} else {

0 commit comments

Comments
 (0)