-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #37004 from VickyStash/ts-migration/installApp-test
[No QA] [TS migration] Migrate 'installApp.js' test to TypeScript
- Loading branch information
Showing
3 changed files
with
27 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import type {ExecException} from 'child_process'; | ||
import execAsync from './execAsync'; | ||
import type {PromiseWithAbort} from './execAsync'; | ||
import * as Logger from './logger'; | ||
|
||
/** | ||
* Installs the app on the currently connected device for the given platform. | ||
* It removes the app first if it already exists, so it's a clean installation. | ||
*/ | ||
export default function (packageName: string, path: string, platform = 'android'): PromiseWithAbort { | ||
if (platform !== 'android') { | ||
throw new Error(`installApp() missing implementation for platform: ${platform}`); | ||
} | ||
|
||
// Uninstall first, then install | ||
return ( | ||
execAsync(`adb uninstall ${packageName}`) | ||
.catch((error: ExecException) => { | ||
// Ignore errors | ||
Logger.warn('Failed to uninstall app:', error); | ||
}) | ||
// eslint-disable-next-line @typescript-eslint/no-misused-promises | ||
.finally(() => execAsync(`adb install ${path}`)) | ||
); | ||
} |