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

Sketch not 'seeing' changes without removing plugin and re-installing #193

Closed
benfrain opened this issue May 16, 2018 · 17 comments

Comments

@benfrain
Copy link

commented May 16, 2018

When I run npm run watch my build is working as expected. However, Sketch is no longer seeing the changes to the local dev version (it was originally).

At present, I have to keep uninstalling the plugin from the Plugin menu and then re-installing by clicking my pluginName.sketchplugin file.

Is there a particular 'flag' I need to set somewhere to get Sketch to update incremental changes when I am developing locally? Is it because I now have a appcast in my manifest (I did try deleting that entry to no avail)?

Any pointers appreciated.

@mathieudutour

This comment has been minimized.

Copy link
Contributor

commented May 16, 2018

Have a look here: https://developer.sketchapp.com/guides/preferences/#always-reload-scripts-before-running

I guess you are using skpm? It should have enabled the setting for you. But perhaps you are now using the Sketch beta and you will need to do it manually.

I'm going to close this as it's not really a bug but more a question

@benfrain

This comment has been minimized.

Copy link
Author

commented May 17, 2018

@mathieudutour thanks for the response, sorry to struggle here; if there is a better medium to discuss please let me know.

I had already got that flag set and it was working initially but now it doesn't. I have re-run that defaults write ~/Library/Preferences/com.bohemiancoding.sketch3.plist AlwaysReloadScript -bool YES command but it still doesn't work.

For example, a simple change to a log() in my js file doesn't get picked up in Sketch without removing the plugin and re-installing. Any further things I can check?

I am using 49.3.

@robintindale

This comment has been minimized.

Copy link
Contributor

commented May 17, 2018

One possibility is that your script is long-running for some reason - this can either be because you're using coscript shouldKeepAround, using a fiber, or your program crashes in a way that doesn't cleanup the context.

If a script is long-running, the plugin won't be reloaded when you run a command again, as it will just re-use the old context. You can find out by running

var pm = AppController.sharedInstance().pluginManager();
var c = pm.runningCommands();
var command = c.objectEnumerator().nextObject()
log(c)

which will log something if your plugin is still running after you execute a command.

@benfrain

This comment has been minimized.

Copy link
Author

commented May 17, 2018

@robintindale Ah, OK, thanks. Could you just clarify, I am currently using:

// Get choice of drop-down from user
    var choice = UI.getSelectionFromUser("Which Language?", listOfLanguages);
    var ok = choice[2];
    var value = listOfLanguages[choice[1]];

    // Once OK is clicked on the menu
    if (ok) {
//...more

I then add your above snippet at the end of that if (ok) which is logging:

{
    "<MSPluginCommandSpecifier: 0x608000223cc0>" = "<MSPluginCommand: 0x6000002e5c00>";
}

Is that log response telling me something in my script is long-running?

@robintindale

This comment has been minimized.

Copy link
Contributor

commented May 17, 2018

ah no, the snippet should be run from the Run Script.. window after your plugin has "completed" - if you run it during execution, it's going to show that your plugin is running (because it still is 😁). Long-running would mean your plugin is running even after you think it's done

@benfrain

This comment has been minimized.

Copy link
Author

commented May 17, 2018

Ha! Glad I asked :)

I get this after first running the plugin and then that command from the Run Script menu:

{
}

Script executed in 0.016127s

Presume that means it isn't that?

I suspect as a newbie, I am doing something obviously stupid as it was working at first.

In case it helps, here is a gist containing my src files (I have omitted mlStrings.js as it is just a JS object of data) and package.json.

https://gist.github.com/benfrain/4914e1a4232ea6037ed20042696d0ae9

@robintindale

This comment has been minimized.

Copy link
Contributor

commented May 17, 2018

Yes, OK looks like it's not a long-running issue.

I just saw that you are reinstalling the plugin each time - this could be the cause, as this will just copy a static version of the files into the Plugins directory, so changing things in your skpm directory won't have any effect. You need to reset a symlink from Plugins to the .sketchplugin in your local skpm directory.

  • Go to ~/Library/Application\ Support/com.bohemiancoding.sketch3/Plugins and delete your plugin
  • in your skpm folder, run ./node_modules/.bin/skpm-link - this should reset the symlink

Give that a go :)

@mathieudutour

This comment has been minimized.

Copy link
Contributor

commented May 17, 2018

Ah yes good thinking! I’m wondering if I can check if there is a symlink when running npm run watch and print a warning. That’s not the first time it happened

@benfrain

This comment has been minimized.

Copy link
Author

commented May 17, 2018

@robintindale when you say the skpm folder, do you just mean the node_modules folder of my own plugin? The only folder I can find on my system related to skpm is @skpm ??

Sorry, realise I'm being a bit of a dunce here!

@mathieudutour

This comment has been minimized.

Copy link
Contributor

commented May 17, 2018

No, in your plugin folder. So that ./node_modules/.bin/skpm-link exists

@robintindale

This comment has been minimized.

Copy link
Contributor

commented May 17, 2018

yep sorry, the folder you are developing your plugin in - where the package.json is :)

@benfrain

This comment has been minimized.

Copy link
Author

commented May 17, 2018

OK, @robintindale said to 'run' the skpm-link - I take it that means from the 'Run script' command?

@robintindale

This comment has been minimized.

Copy link
Contributor

commented May 17, 2018

no, from a Terminal window in your plugin directory 👍

@benfrain

This comment has been minimized.

Copy link
Author

commented May 17, 2018

Sorry, not having any joy with that?

screen shot 2018-05-17 at 16 53 31

@mathieudutour

This comment has been minimized.

Copy link
Contributor

commented May 17, 2018

that's what you need to run:

cd ~/Sites/TranslateText && ./node_modules/.bin/skpm-link
@robintindale

This comment has been minimized.

Copy link
Contributor

commented May 17, 2018

And a hint for why it wasn't working - if you're trying to run a file in the current directory, you need to prefix ./, so if you're in ~/Sites/TranslateText/node_modules/.bin, you'd need to execute ./skpm-link. Otherwise, it will just look in your normal $PATH and not find anything

@benfrain

This comment has been minimized.

Copy link
Author

commented May 17, 2018

@mathieudutour @robintindale thanks men, running great again now! Thanks for your patience 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.