-
Notifications
You must be signed in to change notification settings - Fork 997
/
run.ts
43 lines (33 loc) · 1.25 KB
/
run.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import Debug from 'debug';
import { resolve } from 'path';
import c from '../colors';
import { promptForPlatformTarget, runTask } from '../common';
import type { Config } from '../definitions';
import type { RunCommandOptions } from '../tasks/run';
import { runNativeRun, getPlatformTargets } from '../util/native-run';
import { runCommand } from '../util/subprocess';
const debug = Debug('capacitor:android:run');
export async function runAndroid(
config: Config,
{ target: selectedTarget }: RunCommandOptions,
): Promise<void> {
const target = await promptForPlatformTarget(
await getPlatformTargets('android'),
selectedTarget,
);
const gradleArgs = ['assembleDebug'];
debug('Invoking ./gradlew with args: %O', gradleArgs);
await runTask('Running Gradle build', async () =>
runCommand('./gradlew', gradleArgs, {
cwd: config.android.platformDirAbs,
}),
);
const apkName = 'app-debug.apk';
const apkPath = resolve(config.android.buildOutputDirAbs, apkName);
const nativeRunArgs = ['android', '--app', apkPath, '--target', target.id];
debug('Invoking native-run with args: %O', nativeRunArgs);
await runTask(
`Deploying ${c.strong(apkName)} to ${c.input(target.id)}`,
async () => runNativeRun(nativeRunArgs),
);
}