MCPcopy Index your code
hub / github.com/Unitech/pm2 / getModuleName

Function getModuleName

lib/API/Modules/TAR.js:252–268  ·  view source on GitHub ↗

* Uncompress only module/package.json and retrieve the "name" attribute in the package.json

(module_filepath, cb)

Source from the content-addressed store, hash-verified

250 * Uncompress only module/package.json and retrieve the "name" attribute in the package.json
251 */
252function getModuleName(module_filepath, cb) {
253 var tmp_folder = path.join(os.tmpdir(), cst.MODULE_BASEFOLDER)
254
255 var install_instance = spawn('tar', ['zxf', module_filepath, '-C', os.tmpdir(), cst.MODULE_BASEFOLDER + '/package.json'], {
256 stdio : 'inherit',
257 env: process.env
258 })
259
260 install_instance.on('close', function(code) {
261 try {
262 var pkg = JSON.parse(fs.readFileSync(path.join(tmp_folder, `package.json`)))
263 return cb(null, pkg.name)
264 } catch(e) {
265 return cb(e)
266 }
267 });
268}
269
270function packager(module_path, target_path, cb) {
271 var base_folder = path.dirname(module_path)

Callers 1

installLocalFunction · 0.85

Calls 3

cbFunction · 0.85
onMethod · 0.65
parseMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…