UNPKG

823 BJavaScriptView Raw
1/*
2 STDOUTSTR := newType('STDOUTSTR', string)
3 description : function to create linux command call and return the stadout as string.
4 requires : cmd - string
5 returns : Optional[STDOUTSTR]
6*/
7module.exports = {
8 systemSync: function(cmd, root_path) {
9 child_process = require('child_process');
10 try {
11 return child_process.execSync(cmd,
12 {
13 cwd: root_path
14 }
15 ).toString();
16 }
17 catch (error) {
18 // HACK - stupid npm exit 1 if contains vulnerability, check stderr first
19 return (error.stderr.toString().length == 0) ? error.stdout.toString() : null
20 }
21 },
22
23
24 get_npm: function(root_path){
25 return this.systemSync("npm -v", root_path)
26 }
27};