Skip to content

Instantly share code, notes, and snippets.

@idleberg
Last active November 17, 2015 15:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save idleberg/ca5714fd2b9607db02b8 to your computer and use it in GitHub Desktop.
Save idleberg/ca5714fd2b9607db02b8 to your computer and use it in GitHub Desktop.
Install npm dependencies (global) for Sublime Packages, e.g. linters
# https://gist.github.com/idleberg/ca5714fd2b9607db02b8
import os, sublime, sublime_plugin, subprocess
# Array of required Node packages
packages = [
''
]
def plugin_loaded():
from package_control import events
from subprocess import check_call
# Get name of package folder
me = os.path.basename(os.path.dirname(os.path.realpath(__file__)))
pkg_dir = sublime.packages_path() + '/' + me
if len(packages) > 0:
for pkg in packages:
if pkg:
print("[%s] npm install -g %s" % ( me, pkg))
os.chdir(pkg_dir)
check_call(['npm', 'install', '-g', pkg])
else:
print("[%s] No package specified" % me)
elif len(packages) == 0 and os.path.isfile(pkg_dir + "/package.json"):
print("[%s] npm install" % me)
os.chdir(pkg_dir)
check_call(['npm', 'install', '-g'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment