* Uncompress only module/package.json and retrieve the "name" attribute in the package.json
(module_filepath, cb)
| 250 | * Uncompress only module/package.json and retrieve the "name" attribute in the package.json |
| 251 | */ |
| 252 | function 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 | |
| 270 | function packager(module_path, target_path, cb) { |
| 271 | var base_folder = path.dirname(module_path) |
no test coverage detected
searching dependent graphs…