Skip to content

Commit

Permalink
fix: Cannot read property '0' of null when SOLIDREGION contains an arc
Browse files Browse the repository at this point in the history
  • Loading branch information
urish committed Feb 4, 2020
1 parent fc76ed1 commit e91d37c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
20 changes: 20 additions & 0 deletions src/board.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -457,4 +457,24 @@ describe('convertLib()', () => {
]
]);
});

it('should not crash if SOLIDREGION contains an arc (issue #20)', () => {
const input =
'LIB~4401~3164~package`IEC_HIGHVOLTAGE_SMALL`~~~gge846~1~~~0~#@$#@$SOLIDREGION~3~~M 4513.5 3294 A 12.125 12.125 0 0 1 4495.5 3294 Z ~solid~gge636~~~~0';

expect(normalize(convertLib(input.split(/~/g).slice(1), ['']))).toEqual([
'module',
'easyeda:IEC_HIGHVOLTAGE_SMALL',
['layer', 'F.Cu'],
['at', 101.854, 41.656],
[
'fp_text',
'user',
'gge846',
['at', 0, 0],
['layer', 'Cmts.User'],
['effects', ['font', ['size', 1, 1], ['thickness', 0.15]]]
]
]);
});
});
2 changes: 1 addition & 1 deletion src/board.ts
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ export function convertLib(args: string[], nets: string[]) {
]);

const modAttrs = [];
const isSmd = shapes.some((shape) => shape[0] === 'pad' && shape[2] === 'smd');
const isSmd = shapes.some((shape) => shape && shape[0] === 'pad' && shape[2] === 'smd');
if (isSmd) {
modAttrs.push(['attr', 'smd']);
}
Expand Down

0 comments on commit e91d37c

Please sign in to comment.