Skip to content

Commit 8986681

Browse files
author
Akos Kitta
committed
fix: config ID creation
Signed-off-by: Akos Kitta <a.kitta@arduino.cc>
1 parent d94793b commit 8986681

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed
Binary file not shown.

src/debug.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,10 +203,15 @@ async function parseRawDebugInfo(
203203
}
204204

205205
function createConfigId(board: BoardIdentifier, programmer: string): string {
206-
return `${board.fqbn
207-
.split(':')
208-
.slice(0, 3)
209-
.join(':')}:programmer=${programmer}`;
206+
const { fqbn } = board;
207+
const [, , , rest] = fqbn.split(':');
208+
if (typeof rest === 'string') {
209+
// if already has config options, append the programmer as an ordinary custom board config option
210+
return `${fqbn},programmer=${programmer}`;
211+
} else {
212+
// create the new config options entry with the programmer as a single entry
213+
return `${fqbn}:programmer=${programmer}`;
214+
}
210215
}
211216

212217
async function loadDebugCustomJson(

src/test/suite/debug.test.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,10 +350,14 @@ describe('debug', () => {
350350
});
351351

352352
describe('createConfigId', () => {
353-
it('should create configuration ID', () => {
353+
it('should create the configuration ID when the FQBN has no custom board options', () => {
354354
const actual = createConfigId({ fqbn: 'a:b:c' }, 'p');
355355
assert.strictEqual(actual, 'a:b:c:programmer=p');
356356
});
357+
it('should create the configuration ID when the FQBN has custom board options', () => {
358+
const actual = createConfigId({ fqbn: 'a:b:c:o1=v1' }, 'p');
359+
assert.strictEqual(actual, 'a:b:c:o1=v1,programmer=p');
360+
});
357361
});
358362

359363
describe('isCustomDebugConfig', () => {

0 commit comments

Comments
 (0)