@tmustier/pi-nes 0.2.20 → 0.2.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -43,15 +43,17 @@ async function selectRom(
43
43
  return null;
44
44
  }
45
45
 
46
- const selection = await ctx.ui.select(
47
- "Select a ROM",
48
- roms.map((rom) => rom.name),
49
- );
46
+ const options = roms.map((rom, index) => `${index + 1}. ${rom.name}`);
47
+ const selection = await ctx.ui.select("Select a ROM", options);
50
48
  if (!selection) {
51
49
  return null;
52
50
  }
53
- const match = roms.find((rom) => rom.name === selection);
54
- return match?.path ?? null;
51
+ const index = options.indexOf(selection);
52
+ if (index < 0) {
53
+ ctx.ui.notify("ROM selection failed. Please try again.", "error");
54
+ return null;
55
+ }
56
+ return roms[index]?.path ?? null;
55
57
  } catch {
56
58
  ctx.ui.notify(`Failed to read ROM directory: ${romDir}. Update ${configPath} to set romDir.`, "error");
57
59
  return null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tmustier/pi-nes",
3
- "version": "0.2.20",
3
+ "version": "0.2.21",
4
4
  "description": "NES emulator extension for pi",
5
5
  "keywords": [
6
6
  "pi-package",