-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from snyk/fix/error-on-bad-gradle-run
fix: throw proper error on failing gradle execution
- Loading branch information
Showing
3 changed files
with
29 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,9 @@ function inspect(root, targetFile, options) { | |
if (!options) { | ||
options = {dev: false}; | ||
} | ||
return getPackage(root, targetFile, options) | ||
var command = getCommand(root, targetFile); | ||
var args = buildArgs(root, targetFile, options.args); | ||
return getPackage(root, command, args) | ||
.then(function (pkg) { | ||
// opt-in with `jars` or `localjars` flag | ||
if (options.jars || options.localjars) { | ||
|
@@ -40,14 +42,19 @@ function inspect(root, targetFile, options) { | |
}, | ||
package: pkg, | ||
}; | ||
}) | ||
.catch(function (error) { | ||
error.message = error.message + '\n\n' + | ||
'Please make sure that `' + command + ' ' + args.join(' ') + | ||
'` executes successfully on this project.\n\n' + | ||
'If the problem persists, collect the output of `' + | ||
command + ' ' + args.join(' ') + '` and contact [email protected]\n'; | ||
throw error; | ||
}); | ||
} | ||
|
||
function getPackage(root, targetFile, options) { | ||
return subProcess.execute( | ||
getCommand(root, targetFile), | ||
buildArgs(root, targetFile, options.args), | ||
{cwd: root}) | ||
function getPackage(root, command, args) { | ||
return subProcess.execute(command, args, {cwd: root}) | ||
.then(function (result) { | ||
var packageName = path.basename(root); | ||
var packageVersion = '0.0.0'; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters