Skip to content

Commit d3c33da

Browse files
committed
add/remove todos
1 parent 8c36f69 commit d3c33da

File tree

3 files changed

+20
-18
lines changed

3 files changed

+20
-18
lines changed

packages/platform-harmony/src/lib/commands/run/command.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export function registerRunCommand(
1313
api.registerCommand({
1414
name: 'run:harmony',
1515
description:
16-
'Builds your app and starts it on a connected HarmonyOS Next emulator or a device.',
16+
'Builds your app and starts it on a connected HarmonyOS Next device.',
1717
action: async (args) => {
1818
const projectRoot = api.getProjectRoot();
1919
const harmonyConfig = getValidProjectConfig(projectRoot, pluginConfig);

packages/platform-harmony/src/lib/commands/run/hdc.ts

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,21 @@ export async function getDevices() {
2222
stdio: 'pipe',
2323
});
2424
const lines = output.trim().split('\n');
25-
return lines.map((line) => {
26-
const parts = line.split(/\s+/);
27-
return {
28-
name: parts[0],
29-
method: parts[1], // USB
30-
state: parts[2], // Connected, Offline
31-
locate: parts[3], // localhost
32-
connectTool: parts[4],
33-
};
34-
});
25+
return (
26+
lines
27+
.map((line) => {
28+
const parts = line.split(/\s+/);
29+
return {
30+
name: parts[0],
31+
method: parts[1], // USB
32+
state: parts[2], // Connected, Offline
33+
locate: parts[3], // localhost
34+
connectTool: parts[4],
35+
};
36+
})
37+
// hdc will report no devices as [Empty] sometimes
38+
.filter((line) => line.state != undefined)
39+
);
3540
} catch {
3641
return [];
3742
}

packages/platform-harmony/src/lib/commands/run/runHarmony.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import type { DeviceData } from './listHarmonyDevices.js';
2121
import { listHarmonyDevices } from './listHarmonyDevices.js';
2222
import { tryInstallAppOnDevice } from './tryInstallAppOnDevice.js';
2323
import { tryLaunchAppOnDevice } from './tryLaunchAppOnDevice.js';
24-
// import { tryLaunchEmulator } from './tryLaunchEmulator.js';
2524

2625
export interface Flags extends BuildFlags {
2726
ability: string;
@@ -69,13 +68,11 @@ export async function runHarmony(
6968
if (device) {
7069
if (device.deviceId) {
7170
if (!binaryPath) {
72-
// @todo fix sourceDir
7371
await runHvigor({ sourceDir, args, artifactName, device, bundleName });
7472
}
7573
await runOnDevice({ device, sourceDir, args, binaryPath, bundleName });
7674
}
7775
} else {
78-
// @todo consider filtering out offline devices
7976
if ((await getDevices()).length === 0) {
8077
if (isInteractive()) {
8178
await selectAndLaunchDevice();
@@ -84,7 +81,6 @@ export async function runHarmony(
8481
'No booted devices or emulators found. Launching first available emulator.',
8582
);
8683
// @todo add emulators
87-
// await tryLaunchEmulator();
8884
}
8985
}
9086

@@ -108,7 +104,6 @@ async function selectAndLaunchDevice() {
108104

109105
if (!device.connected) {
110106
// @todo add emulators
111-
// await tryLaunchEmulator(device.readableName);
112107
// list devices once again when emulator is booted
113108
const allDevices = await listHarmonyDevices();
114109
const newDevice =
@@ -155,11 +150,13 @@ async function promptForDeviceSelection(
155150
): Promise<DeviceData> {
156151
if (!allDevices.length) {
157152
throw new RockError(
158-
'No devices and/or emulators connected. Please create emulator with DevEco Studio or connect HarmonyOS device.',
153+
// @todo add emulators
154+
'No devices connected. Please create connect HarmonyOS device.',
159155
);
160156
}
161157
const selected = await promptSelect({
162-
message: 'Select the device / emulator you want to use',
158+
// @todo add emulators
159+
message: 'Select the device you want to use',
163160
options: allDevices.map((d) => ({
164161
label: `${d.readableName}${
165162
d.type === 'phone' ? ' - (physical device)' : ''

0 commit comments

Comments
 (0)