generated from dankeboy36/esp-exception-decoder
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add support for
withFQBN
(#18)
This feature allows the creation of an FQBN from the root FQBN, incorporating configuration options from the CLI while also allowing for overwrites with previously persisted options appended to the FQBN. Signed-off-by: dankeboy36 <[email protected]>
- Loading branch information
1 parent
c22ae58
commit b0eb2ad
Showing
11 changed files
with
206 additions
and
18 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 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 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 |
---|---|---|
@@ -1,21 +1,21 @@ | ||
import assert from 'node:assert/strict'; | ||
import { FQBN } from '../index'; | ||
|
||
// valid FQBN | ||
// Valid FQBN. | ||
const fqbn1 = new FQBN('arduino:samd:mkr1000'); | ||
assert.ok(fqbn1); | ||
assert.strictEqual(fqbn1.vendor, 'arduino'); | ||
assert.strictEqual(fqbn1.arch, 'samd'); | ||
assert.strictEqual(fqbn1.boardId, 'mkr1000'); | ||
assert.strictEqual(fqbn1.options, undefined); | ||
|
||
// valid FQBN with custom board options | ||
// Valid FQBN with custom board options. | ||
const fqbn2 = new FQBN('arduino:samd:mkr1000:o1=v1'); | ||
assert.ok(fqbn2); | ||
assert.strictEqual(fqbn2.vendor, 'arduino'); | ||
assert.strictEqual(fqbn2.arch, 'samd'); | ||
assert.strictEqual(fqbn2.boardId, 'mkr1000'); | ||
assert.deepStrictEqual(fqbn2.options, { o1: 'v1' }); | ||
|
||
// invalid FQBN | ||
// Invalid FQBN. | ||
assert.throws(() => new FQBN('invalid')); |
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 |
---|---|---|
@@ -1,12 +1,12 @@ | ||
import assert from 'node:assert/strict'; | ||
import { FQBN } from '../index'; | ||
|
||
// removes the custom board config options | ||
// Removes the custom board config options. | ||
assert.strictEqual( | ||
new FQBN('arduino:samd:mkr1000:o1=v1,o2=v2').sanitize().toString(), | ||
'arduino:samd:mkr1000' | ||
); | ||
|
||
// returns the same instance when no custom board options are available | ||
// Returns the same instance when no custom board options are available. | ||
const fqbn = new FQBN('arduino:samd:mkr1000'); | ||
assert.ok(fqbn === fqbn.sanitize()); |
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 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 |
---|---|---|
@@ -1,9 +1,9 @@ | ||
import assert from 'node:assert/strict'; | ||
import { FQBN, valid } from '../index'; | ||
|
||
// valid FQBN | ||
// Valid FQBN. | ||
assert.ok(valid('arduino:samd:mkr1000') instanceof FQBN); | ||
assert.ok(valid('arduino:samd:mkr1000:o1=v1') instanceof FQBN); | ||
|
||
// invalid FQBN | ||
// Invalid FQBN. | ||
assert.strictEqual(valid('invalid'), undefined); |
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 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,27 @@ | ||
import assert from 'node:assert/strict'; | ||
import { FQBN } from '../index'; | ||
|
||
// Creates a new FQBN instance by appending the custom board options extracted from the other FQBN to the end of the original FQBN. | ||
const fqbn1 = new FQBN('arduino:samd:mkr1000'); | ||
const fqbn2 = fqbn1.withFQBN('arduino:samd:mkr1000:o1=v1'); | ||
assert.strictEqual(fqbn2.vendor, 'arduino'); | ||
assert.strictEqual(fqbn2.arch, 'samd'); | ||
assert.strictEqual(fqbn2.boardId, 'mkr1000'); | ||
assert.deepStrictEqual(fqbn2.options, { o1: 'v1' }); | ||
|
||
// FQBNs are immutable. | ||
assert.strictEqual(fqbn1.options, undefined); | ||
assert.ok(fqbn2.options); | ||
|
||
// Always maintains the position of existing configuration option keys while updating the selected value. | ||
const fqbn3 = fqbn2.withFQBN('arduino:samd:mkr1000:o2=v2,o1=v2'); | ||
assert.deepStrictEqual(fqbn3.options, { o1: 'v2', o2: 'v2' }); | ||
assert.deepStrictEqual(fqbn3.toString(), 'arduino:samd:mkr1000:o1=v2,o2=v2'); | ||
|
||
// Never removes config options. | ||
const fqbn4 = fqbn3.withFQBN('arduino:samd:mkr1000'); | ||
assert.deepStrictEqual(fqbn4.options, { o1: 'v2', o2: 'v2' }); | ||
assert.deepStrictEqual(fqbn4.toString(), 'arduino:samd:mkr1000:o1=v2,o2=v2'); | ||
|
||
// Errors on mismatching FQBNs. | ||
assert.throws(() => fqbn4.withFQBN('arduino:avr:uno:o1=v3')); |
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 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 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