Skip to content

Commit

Permalink
add suggested changes
Browse files Browse the repository at this point in the history
Signed-off-by: Aryan Rajoria <[email protected]>
  • Loading branch information
aryan-rajoria committed Sep 6, 2024
1 parent 622223b commit 57df0b7
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 15 deletions.
8 changes: 4 additions & 4 deletions envcontext.js
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ export function installSdkmanTool(toolType, toolName) {
*
* @returns {String} path of nvm if present, otherwise false
*/
export function ifNvmToolAvailable(toolName) {
export function getNvmToolDirectory(toolName) {
const resultWhichNode = spawnSync(
process.env.SHELL || "bash",
["-i", "-c", `"nvm which ${toolName}"`],
Expand Down Expand Up @@ -544,8 +544,8 @@ export function ifNvmToolAvailable(toolName) {
*
* @returns {String} path of the tool if not found installs and then returns paths. false if encounters an error.
*/
export function getNvmToolPath(toolVersion) {
const nvmNodePath = ifNvmToolAvailable(toolVersion);
export function getOrInstallNvmTool(toolVersion) {
const nvmNodePath = getNvmToolDirectory(toolVersion);
if (!nvmNodePath) {
// nvm couldn't directly use toolName so maybe needs to be installed
const resultInstall = spawnSync(
Expand All @@ -571,7 +571,7 @@ export function getNvmToolPath(toolVersion) {
// output has already been printed out
return false;
}
const nvmNodePath = ifNvmToolAvailable(toolVersion);
const nvmNodePath = getNvmToolDirectory(toolVersion);
if (nvmNodePath) {
return nvmNodePath;
}
Expand Down
11 changes: 4 additions & 7 deletions pregen.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { arch, platform, tmpdir } from "node:os";
import { delimiter, join } from "node:path";
import {
SDKMAN_TOOL_ALIASES,
getNvmToolPath,
ifNvmToolAvailable,
getNvmToolDirectory,
getOrInstallNvmTool,
installSdkmanTool,
isNvmAvailable,
isSdkmanAvailable,
Expand Down Expand Up @@ -156,7 +156,7 @@ export function prepareNodeEnv(filePath, options) {
}
}
// set path instead of nvm use
const nvmNodePath = getNvmToolPath(nodeVersion);
const nvmNodePath = getOrInstallNvmTool(nodeVersion);
doNpmInstall(filePath, nvmNodePath);
}
}
Expand Down Expand Up @@ -188,11 +188,8 @@ export function tryLoadNvmAndInstallTool(nodeVersion) {
encoding: "utf-8",
shell: process.env.SHELL || true,
});
if (spawnedShell.status === 0) {
return true;
}

return false;
return result.status === 0;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions types/envcontext.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,15 +174,15 @@ export function installSdkmanTool(toolType: string, toolName: string): boolean;
*
* @returns {String} path of nvm if present, otherwise false
*/
export function ifNvmToolAvailable(toolName: string): string;
export function getNvmToolDirectory(toolName: string): string;
/**
* Method to return nvm tool path
*
* @param {String} toolVersion Tool name with version. Eg: 22.0.2-tem
*
* @returns {String} path of the tool if not found installs and then returns paths. false if encounters an error.
*/
export function getNvmToolPath(toolVersion: string): string;
export function getOrInstallNvmTool(toolVersion: string): string;
export const GIT_COMMAND: any;
export namespace SDKMAN_TOOL_ALIASES {
let java8: string;
Expand Down
2 changes: 1 addition & 1 deletion types/envcontext.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion types/pregen.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 57df0b7

Please sign in to comment.