Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

skpm breaking my plugin #300

Open
eaugustine opened this issue Feb 6, 2022 · 2 comments
Open

skpm breaking my plugin #300

eaugustine opened this issue Feb 6, 2022 · 2 comments

Comments

@eaugustine
Copy link

eaugustine commented Feb 6, 2022

I have a really small plugin that works fine, but when I use skpm to publish it, a bunch of extra code is added to the .sketchplugin file and causes it not to work. I'm using skpm so that it'll update in the Sketch Plugin library, but I don't need all the template stuff.

Sketch DevTools shows this when I run my plugin:

MOJavaScriptException: Error: Missing export named "inPage". Your command should contain something like `export function " + key +"() {}`.

I'm not sure why though, my plugin works fine when I run it directly from the plugin file before doing skpm build; this is all it is:

// Counts the number of artboards in the Sketch file
function inFile(context) {
	var sketch = require('sketch');
	var doc = context.document;
	const documentData = sketch.getSelectedDocument().sketchObject.documentData();
	var countFile = (documentData.allArtboards().count());
		doc.showMessage("This document has "+ countFile +" artboards");			
}

// Counts the number of artboards in the current page
function inPage(context) {
	var sketch = require('sketch');
	var doc = context.document;
	const currentPage = sketch.getSelectedDocument().selectedPage.sketchObject;
	var countPage = (currentPage.artboards().count());
		doc.showMessage("This page has "+ countPage +" artboards");
}

I'm not a developer and have been stumbling my way through all this; any help is appreciated 😅

@mathieudutour
Copy link
Member

change it to

export function inFile...

export function inPage...

and it should work

@eaugustine
Copy link
Author

It still doesn't work =(

I get: SyntaxError: Unexpected keyword 'export'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants