diff --git a/lib/service/packageDetailsProvider.js b/lib/service/packageDetailsProvider.js index 86a32a4..b906ddd 100644 --- a/lib/service/packageDetailsProvider.js +++ b/lib/service/packageDetailsProvider.js @@ -16,12 +16,28 @@ module.exports = function PackageDetailsProvider() { utils.exec('git clone {0} {1} --depth=1'.format(packageUrl, gitCloneFolder)) .then(function() { var bowerJsonLocation = path.join(gitCloneFolder, 'bower.json'); - - var fileContent = fs.readFileSync(bowerJsonLocation); - var bowerJson = JSON.parse(fileContent); - + var bowerJsonIsExist = true; + var fileContent; + var bowerJson; + + try { + fs.accessSync(bowerJsonLocation); + } + catch (e) { + bowerJsonIsExist = false; + } + + if (bowerJsonIsExist) { + fileContent = fs.readFileSync(bowerJsonLocation); + bowerJson = JSON.parse(fileContent); + } + else { + bowerJson = 'Not found bower.json in this package'; + + } + utils.removeDirectory(gitCloneFolder); - + resolve(bowerJson); }) .catch(reject);