Skip to content

Commit 574256d

Browse files
jezdezdbast
andauthored
fix: remove accidental indentation from shell config template strings (#435)
* fix: remove accidental indentation from shell config template strings Fixes #422 The template strings (bashExtraText, powerExtraText, batchExtraText) had 2-space indentation inherited from TypeScript code formatting. This indentation was written to shell config files like .xonshrc, breaking xonsh's Python-based syntax. Refactored to use array.join() pattern which is immune to auto-formatter indentation changes. * Commit result of `npm run format` --------- Co-authored-by: Daniel Bast <[email protected]>
1 parent 1998b40 commit 574256d

2 files changed

Lines changed: 73 additions & 59 deletions

File tree

‎dist/setup/index.js‎

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

‎src/conda.ts‎

Lines changed: 46 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -419,47 +419,64 @@ export async function condaInit(
419419
}
420420

421421
// PowerShell profiles
422-
let powerExtraText = `
423-
# ----------------------------------------------------------------------------`;
422+
// NOTE: Using array.join() to prevent auto-formatters from adding indentation
423+
const powerLines: string[] = [
424+
"",
425+
"# ----------------------------------------------------------------------------",
426+
];
424427
if (isValidActivate) {
425-
powerExtraText += `
426-
# Conda Setup Action: Custom activation
427-
conda activate "${inputs.activateEnvironment}"`;
428+
powerLines.push(
429+
"# Conda Setup Action: Custom activation",
430+
`conda activate "${inputs.activateEnvironment}"`,
431+
);
428432
}
429-
powerExtraText += `
430-
# ----------------------------------------------------------------------------`;
433+
powerLines.push(
434+
"# ----------------------------------------------------------------------------",
435+
);
436+
const powerExtraText = powerLines.join("\n");
431437

432438
// Bash profiles
433-
let bashExtraText: string = `
434-
# ----------------------------------------------------------------------------
435-
# Conda Setup Action: Basic configuration
436-
set -eo pipefail`;
439+
// NOTE: Using array.join() to prevent auto-formatters from adding indentation
440+
const bashLines: string[] = [
441+
"",
442+
"# ----------------------------------------------------------------------------",
443+
"# Conda Setup Action: Basic configuration",
444+
"set -eo pipefail",
445+
];
437446
if (isValidActivate) {
438-
bashExtraText += `
439-
# Conda Setup Action: Custom activation
440-
conda activate "${inputs.activateEnvironment}"`;
441-
bashExtraText += `
442-
# ----------------------------------------------------------------------------`;
447+
bashLines.push(
448+
"# Conda Setup Action: Custom activation",
449+
`conda activate "${inputs.activateEnvironment}"`,
450+
"# ----------------------------------------------------------------------------",
451+
);
443452
}
453+
const bashExtraText = bashLines.join("\n");
444454

445455
// Batch profiles
446-
let batchExtraText = `
447-
:: ---------------------------------------------------------------------------`;
456+
// NOTE: Using array.join() to prevent auto-formatters from adding indentation
457+
const batchLines: string[] = [
458+
"",
459+
":: ---------------------------------------------------------------------------",
460+
];
448461
if (autoActivateDefault) {
449-
batchExtraText += `
450-
:: Conda Setup Action: Activate default environment
451-
@CALL "%CONDA_BAT%" activate`;
462+
batchLines.push(
463+
":: Conda Setup Action: Activate default environment",
464+
'@CALL "%CONDA_BAT%" activate',
465+
);
452466
}
453467
if (isValidActivate) {
454-
batchExtraText += `
455-
:: Conda Setup Action: Custom activation
456-
@CALL "%CONDA_BAT%" activate "${inputs.activateEnvironment}"`;
468+
batchLines.push(
469+
":: Conda Setup Action: Custom activation",
470+
`@CALL "%CONDA_BAT%" activate "${inputs.activateEnvironment}"`,
471+
);
457472
}
458-
batchExtraText += `
459-
:: Conda Setup Action: Basic configuration
460-
@SETLOCAL EnableExtensions
461-
@SETLOCAL DisableDelayedExpansion
462-
:: ---------------------------------------------------------------------------`;
473+
batchLines.push(
474+
":: Conda Setup Action: Basic configuration",
475+
"@SETLOCAL EnableExtensions",
476+
"@SETLOCAL DisableDelayedExpansion",
477+
":: ---------------------------------------------------------------------------",
478+
);
479+
const batchExtraText = batchLines.join("\n");
463480

464481
const shells: types.IShells = {
465482
"~/.bash_profile": bashExtraText,

0 commit comments

Comments
 (0)