Skip to content

Commit

Permalink
fix(sketch): add undefined exception handler in icon generate script (#…
Browse files Browse the repository at this point in the history
…5583)

* chore: add log script

* chore: fix typo

* fix(sketch): handle undefined exception
  • Loading branch information
emyarod authored Mar 19, 2020
1 parent 122af4a commit a301044
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/sketch/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"build": "cross-env NODE_ENV=production skpm-build",
"clean": "rimraf carbon-elements.sketchplugin",
"develop": "cross-env NODE_ENV=development skpm-build --watch",
"log": "skpm log -f",
"skpm:link": "skpm-link"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/sketch/src/commands/command.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export function command(name, fn) {
sketch.UI.message('Done! 🎉');
} catch (error) {
console.log(error);
sketch.UI.message('An error occured, please check the development logs');
sketch.UI.message('An error occurred, please check the development logs');
}

if (process.env.NODE_ENV === 'development') {
Expand Down
5 changes: 5 additions & 0 deletions packages/sketch/src/commands/icons/generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ export function generate() {
const [_type, _category, _subcategory, name, size] = parts;
return name === icon && size === '32';
});

if (!symbol) {
throw new Error(`Unable to find symbol for icon ${icon}!`);
}

const instance = symbol.createNewInstance();
instance.frame.offset(ICON_X_OFFSET, ICON_Y_OFFSET);

Expand Down

0 comments on commit a301044

Please sign in to comment.