Skip to content

Commit

Permalink
fix initial start, ask for uninstall
Browse files Browse the repository at this point in the history
  • Loading branch information
fcannizzaro committed Jun 23, 2017
1 parent 484ed8c commit 59e9704
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions npm-install.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import re

MODULE = r'.*require\(["\']([^.][^\.]*?)["\']\).*'
ICON = "Packages/npm-install/icon-%s.png"
data = {}
root = {}

Expand Down Expand Up @@ -53,8 +54,8 @@ def update_icons(view):
result.append(module)

flags = sublime.HIDE_ON_MINIMAP | sublime.DRAW_NO_FILL | sublime.DRAW_NO_OUTLINE | sublime.DRAW_SOLID_UNDERLINE
view.add_regions('require-on', installed, 'request', 'Packages/npm-install/icon-on.png', flags)
view.add_regions('require-off', other, 'request', 'Packages/npm-install/icon-off.png', flags)
view.add_regions('require-on', installed, 'request', ICON % 'on', flags)
view.add_regions('require-off', other, 'request', ICON % 'off', flags)

return result

Expand Down Expand Up @@ -124,17 +125,25 @@ def is_visible(self):
def run(self, edit):
if is_valid(self.view):
region, module = line(self.view)
self.view.erase(edit, region)
NpmExec(module, cwd(self.view), 'uninstall', self.view).start()
reply = sublime.yes_no_cancel_dialog('Remove "%s" module?' % module, 'Yes', 'No')
if reply == 1:
self.view.erase(edit, region)
NpmExec(module, cwd(self.view), 'uninstall', self.view).start()

class EventEditor(sublime_plugin.EventListener):
def on_modified_async(self, view):

def on_modified(self, view):
view.run_command('npm_install', {'action':'mark'})

def on_load_async(self, view):
def on_load(self, view):
view.run_command('npm_install', {'action':'initial'})

def on_post_save_async(self, view):
def on_post_save(self, view):
if install_on_save:
view.run_command('npm_install')

def plugin_loaded():
for win in sublime.windows():
for view in win.views():
view.run_command('npm_install', {'action':'initial'})

0 comments on commit 59e9704

Please sign in to comment.