MCPcopy
hub / github.com/Unitech/pm2 / installLocal

Function installLocal

lib/API/Modules/TAR.js:75–106  ·  view source on GitHub ↗
(PM2, module_filepath, opts, cb)

Source from the content-addressed store, hash-verified

73}
74
75function 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
108function deleteModulePath(module_name) {
109 var sanitized = module_name.replace(/\./g, '')

Callers 1

installFunction · 0.85

Calls 5

getModuleNameFunction · 0.85
cbFunction · 0.85
runInstallFunction · 0.85
exitCliMethod · 0.80
onMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…