Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def cmd(self, command, module):
# create node_modules
home = Environment.pixiedustHome
node_home = os.path.join(home,'node')
node_modules = os.path.join(node_home,'node_modules')
if not os.path.exists(node_modules):
os.makedirs(node_modules)
# create sub-process
npm_path = self.which('npm')
args = [npm_path, command, '-s']
if (module):
if (isinstance(module, str)):
args.append(module)
else:
args.extend(module)
print (' '.join(args))
ps = subprocess.Popen( args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, cwd = node_home)
def __init__(self):
"""
Establishes the Node's home directories and executable paths
"""
# get the home directory
home = Environment.pixiedustHome
# Node home directory
self.node_home = os.path.join(home, 'node')
if not os.path.exists(self.node_home):
os.makedirs(self.node_home)
# Node modules home directory
self.node_modules = os.path.join(self.node_home, 'node_modules')
if not os.path.exists(self.node_modules):
os.makedirs(self.node_modules)
self.node_prog = 'node'
self.npm_prog = 'npm'
if platform.system() == 'Windows':
self.node_prog += '.exe'
self.npm_prog += '.cmd'