Last active
November 17, 2015 15:48
-
-
Save idleberg/ca5714fd2b9607db02b8 to your computer and use it in GitHub Desktop.
Install npm dependencies (global) for Sublime Packages, e.g. linters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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