Skip to content

Commit

Permalink
Refactor convertInstallPathToAbsolute
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikolai Laevskii committed May 24, 2023
1 parent abf9166 commit df506c2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 21 deletions.
15 changes: 5 additions & 10 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,6 @@ class DotnetInstallScript {
setupScriptBash() {
return __awaiter(this, void 0, void 0, function* () {
(0, fs_1.chmodSync)(this.escapedScript, '777');
this.scriptArguments = [];
this.scriptPath = yield io.which(this.escapedScript, true);
});
}
Expand Down Expand Up @@ -385,15 +384,11 @@ class DotnetInstallScript {
exports.DotnetInstallScript = DotnetInstallScript;
class DotnetInstallDir {
static convertInstallPathToAbsolute(installDir) {
let transformedPath;
if (path_1.default.isAbsolute(installDir)) {
transformedPath = installDir;
}
else {
transformedPath = installDir.startsWith('~')
? path_1.default.join(os_1.default.homedir(), installDir.slice(1))
: (transformedPath = path_1.default.join(process.cwd(), installDir));
}
if (path_1.default.isAbsolute(installDir))
return path_1.default.normalize(installDir);
const transformedPath = installDir.startsWith('~')
? path_1.default.join(os_1.default.homedir(), installDir.slice(1))
: path_1.default.join(process.cwd(), installDir);
return path_1.default.normalize(transformedPath);
}
static addToPath() {
Expand Down
17 changes: 6 additions & 11 deletions src/installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,6 @@ export class DotnetInstallScript {

private async setupScriptBash() {
chmodSync(this.escapedScript, '777');

this.scriptArguments = [];

this.scriptPath = await io.which(this.escapedScript, true);
}

Expand Down Expand Up @@ -214,14 +211,12 @@ export abstract class DotnetInstallDir {
: DotnetInstallDir.default[getPlatform()];

private static convertInstallPathToAbsolute(installDir: string): string {
let transformedPath;
if (path.isAbsolute(installDir)) {
transformedPath = installDir;
} else {
transformedPath = installDir.startsWith('~')
? path.join(os.homedir(), installDir.slice(1))
: (transformedPath = path.join(process.cwd(), installDir));
}
if (path.isAbsolute(installDir)) return path.normalize(installDir);

const transformedPath = installDir.startsWith('~')
? path.join(os.homedir(), installDir.slice(1))
: path.join(process.cwd(), installDir);

return path.normalize(transformedPath);
}

Expand Down

0 comments on commit df506c2

Please sign in to comment.