Skip to content

Commit

Permalink
Issue #208 - Do not move non-existing files
Browse files Browse the repository at this point in the history
This is a small improvement to not try to move .bashrc into .profile if
.bashrc does not even exists.

This is needed for non-ephemeral self-hosted Github Actions runners
where one VM could run multiple runners
  • Loading branch information
martin-g committed Dec 29, 2021
1 parent 27743c3 commit f5bbd6a
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions src/conda.ts
Expand Up @@ -205,17 +205,23 @@ export async function condaInit(
await condaCommand(["init", cmd], options);
}

// Rename files
if (constants.IS_LINUX) {
let source: string = "~/.bashrc".replace("~", os.homedir());
let dest: string = "~/.profile".replace("~", os.homedir());
core.info(`Renaming "${source}" to "${dest}"\n`);
await io.mv(source, dest);
} else if (constants.IS_MAC) {
let source: string = "~/.bash_profile".replace("~", os.homedir());
let dest: string = "~/.profile".replace("~", os.homedir());
core.info(`Renaming "${source}" to "${dest}"\n`);
await io.mv(source, dest);
if (inputs.removeProfiles == "true") {
// Rename files
if (constants.IS_LINUX) {
let source: string = "~/.bashrc".replace("~", os.homedir());
let dest: string = "~/.profile".replace("~", os.homedir());
if (fs.existsSync(source)) {
core.info(`Renaming "${source}" to "${dest}"\n`);
await io.mv(source, dest);
}
} else if (constants.IS_MAC) {
let source: string = "~/.bash_profile".replace("~", os.homedir());
let dest: string = "~/.profile".replace("~", os.homedir());
if (fs.existsSync(source)) {
core.info(`Renaming "${source}" to "${dest}"\n`);
await io.mv(source, dest);
}
}
}

// PowerShell profiles
Expand Down

0 comments on commit f5bbd6a

Please sign in to comment.