(code)
| 223 | }); |
| 224 | |
| 225 | function finalizeInstall(code) { |
| 226 | if (code != 0) { |
| 227 | // If install has failed, revert to previous module version |
| 228 | return Rollback.revert(CLI, module_name, function() { |
| 229 | return cb(new Error('Installation failed via NPM, module has been restored to prev version')); |
| 230 | }); |
| 231 | } |
| 232 | |
| 233 | Common.printOut(cst.PREFIX_MSG_MOD + 'Module downloaded'); |
| 234 | |
| 235 | var proc_path = path.join(install_path, 'node_modules', canonic_module_name); |
| 236 | var package_json_path = path.join(proc_path, 'package.json'); |
| 237 | |
| 238 | // Append default configuration to module configuration |
| 239 | try { |
| 240 | var conf = JSON.parse(fs.readFileSync(package_json_path).toString()).config; |
| 241 | |
| 242 | if (conf) { |
| 243 | Object.keys(conf).forEach(function(key) { |
| 244 | Configuration.setSyncIfNotExist(canonic_module_name + ':' + key, conf[key]); |
| 245 | }); |
| 246 | } |
| 247 | } catch(e) { |
| 248 | Common.printError(e); |
| 249 | } |
| 250 | |
| 251 | opts = Common.extend(opts, { |
| 252 | cmd : package_json_path, |
| 253 | development_mode : false, |
| 254 | proc_path : proc_path |
| 255 | }); |
| 256 | |
| 257 | Configuration.set(cst.MODULE_CONF_PREFIX + ':' + canonic_module_name, { |
| 258 | uid : opts.uid, |
| 259 | gid : opts.gid |
| 260 | }, function(err, data) { |
| 261 | if (err) return cb(err); |
| 262 | |
| 263 | StartModule(CLI, opts, function(err, dt) { |
| 264 | if (err) return cb(err); |
| 265 | |
| 266 | if (process.env.PM2_PROGRAMMATIC === 'true') |
| 267 | return cb(null, dt); |
| 268 | |
| 269 | CLI.conf(canonic_module_name, function() { |
| 270 | Common.printOut(cst.PREFIX_MSG_MOD + 'Module successfully installed and launched'); |
| 271 | Common.printOut(cst.PREFIX_MSG_MOD + 'Checkout module options: `$ pm2 conf`'); |
| 272 | return cb(null, dt); |
| 273 | }); |
| 274 | }); |
| 275 | }); |
| 276 | } |
| 277 | } |
| 278 | |
| 279 | function start(PM2, modules, module_name, cb) { |
nothing calls this directly
no test coverage detected
searching dependent graphs…