diff --git a/Tasks/JavaToolInstallerV0/javatoolinstaller.ts b/Tasks/JavaToolInstallerV0/javatoolinstaller.ts index f226f52e4b0b..8c8ed14614b8 100644 --- a/Tasks/JavaToolInstallerV0/javatoolinstaller.ts +++ b/Tasks/JavaToolInstallerV0/javatoolinstaller.ts @@ -86,8 +86,10 @@ async function getJava(versionSpec: string) { } /** - * Return file ending if it is supported. Otherwise throw an error. + * Get file ending if it is supported. Otherwise throw an error. + * Find file ending, not extension. For example, there is supported .tar.gz file ending but the extension is .gz. * @param file Path to a file. + * @returns string */ function getSupportedFileEnding(file: string): string { const fileEnding: string = supportedFileEndings.find(ending => file.endsWith(ending)); @@ -104,6 +106,7 @@ function getSupportedFileEnding(file: string): string { * @param sourceFile Path to JDK file. * @param fileExtension JDK file extension. * @param archiveExtractLocation Path to folder to extract a JDK. + * @returns string */ async function installJDK(sourceFile: string, fileExtension: string, archiveExtractLocation: string, extendedJavaHome: string, versionSpec: string): Promise { let jdkDirectory; @@ -140,6 +143,7 @@ async function installJDK(sourceFile: string, fileExtension: string, archiveExtr * Get the path to a folder inside the VOLUMES_FOLDER. * Only for macOS. * @param volumes VOLUMES_FOLDER contents before attaching a disk image. + * @returns string */ function getVolumePath(volumes: Set): string { const newVolumes: string[] = fs.readdirSync(VOLUMES_FOLDER).filter(volume => !volumes.has(volume)); @@ -154,6 +158,7 @@ function getVolumePath(volumes: Set): string { * Get path to a .pkg file. * Only for macOS. * @param volumePath Path to the folder containing a .pkg file. + * @returns string */ function getPackagePath(volumePath: string): string { const packages: string[] = fs.readdirSync(volumePath).filter(file => file.endsWith('.pkg')); @@ -202,12 +207,14 @@ async function installPkg(pkgPath: string, extendedJavaHome: string, versionSpec /** * Install a .pkg file. * Only for macOS. + * Returns promise with return code. * @param pkgPath Path to a .pkg file. + * @returns number */ -async function runPkgInstaller(pkgPath: string): Promise { +async function runPkgInstaller(pkgPath: string): Promise { const installer = sudo('installer'); installer.line(`-package "${pkgPath}" -target /`); - await installer.exec(); + return await installer.exec(); } run(); diff --git a/Tasks/JavaToolInstallerV0/taskutils.ts b/Tasks/JavaToolInstallerV0/taskutils.ts index 084aa02b9e73..c767b478b22b 100644 --- a/Tasks/JavaToolInstallerV0/taskutils.ts +++ b/Tasks/JavaToolInstallerV0/taskutils.ts @@ -14,6 +14,7 @@ export function sleepFor(sleepDurationInMilliSeconds: number): Promise { * Build a path to file in local root. * @param localPathRoot Path to the folder where file should be located. * @param fileNameAndPath Path to the file which name should be taken. + * @returns string */ export function buildFilePath(localPathRoot: string, fileNameAndPath: string): string { const fileName = fileNameAndPath.split(/[\\\/]/).pop(); @@ -25,6 +26,7 @@ export function buildFilePath(localPathRoot: string, fileNameAndPath: string): s /** * Run a tool with `sudo` on Linux and macOS. * Precondition: `toolName` executable is in PATH. + * @returns ToolRunner */ export function sudo(toolName: string): ToolRunner { if (os.platform() === 'win32') { @@ -38,22 +40,26 @@ export function sudo(toolName: string): ToolRunner { /** * Attach a disk image. * Only for macOS. + * Returns promise with return code. * @param sourceFile Path to a disk image file. + * @returns number */ -export async function attach(sourceFile: string): Promise { +export async function attach(sourceFile: string): Promise { console.log(tl.loc('AttachDiskImage')); const hdiutil = sudo('hdiutil'); hdiutil.line(`attach "${sourceFile}"`); - await hdiutil.exec(); + return await hdiutil.exec(); } /** * Detach a disk image. + * Returns promise with return code. * @param volumePath Path to the attached disk image. + * @returns number */ -export async function detach(volumePath: string): Promise { +export async function detach(volumePath: string): Promise { console.log(tl.loc('DetachDiskImage')); const hdiutil = sudo('hdiutil'); hdiutil.line(`detach "${volumePath}"`); - await hdiutil.exec(); + return await hdiutil.exec(); } \ No newline at end of file