(PM2, module_filepath, opts, cb)
| 73 | } |
| 74 | |
| 75 | function installLocal(PM2, module_filepath, opts, cb) { |
| 76 | Common.logMod(`Installing package ${module_filepath}`) |
| 77 | |
| 78 | // Get module name by unpacking the module/package.json only and read the name attribute |
| 79 | getModuleName(module_filepath, function(err, module_name) { |
| 80 | if (err) return cb(err) |
| 81 | |
| 82 | Common.logMod(`Module name is ${module_name}`) |
| 83 | |
| 84 | Common.logMod(`Depackaging module...`) |
| 85 | |
| 86 | var install_path = path.join(cst.DEFAULT_MODULE_PATH, module_name); |
| 87 | |
| 88 | fs.mkdirSync(install_path, { recursive: true }) |
| 89 | |
| 90 | var install_instance = spawn('tar', ['zxf', module_filepath, '-C', install_path, '--strip-components', '1'], { |
| 91 | stdio : 'inherit', |
| 92 | env: process.env |
| 93 | }) |
| 94 | |
| 95 | install_instance.on('close', function(code) { |
| 96 | Common.logMod(`Module depackaged in ${install_path}`) |
| 97 | if (code == 0) |
| 98 | return runInstall(PM2, install_path, module_name, opts, cb) |
| 99 | return PM2.exitCli(1) |
| 100 | }); |
| 101 | |
| 102 | install_instance.on('error', function (err) { |
| 103 | console.error(err.stack || err); |
| 104 | }); |
| 105 | }) |
| 106 | } |
| 107 | |
| 108 | function deleteModulePath(module_name) { |
| 109 | var sanitized = module_name.replace(/\./g, '') |
no test coverage detected
searching dependent graphs…