getDangerJSMetaData method
Implementation
Future<DangerJSMetadata> getDangerJSMetaData(ArgResults args,
{Shell? shell}) async {
var dangerJSExecutable = '';
if (args['danger-js-path'] != null) {
logger.i('Finind out danger from --danger-js-path');
final path = args['danger-js-path'];
final file = File(path);
if (file.existsSync()) {
dangerJSExecutable = path;
} else {
throw 'please provide the corrent path for --danger-js-path';
}
} else {
logger.i('Finding out where the danger executable is');
final dangerJS = whichSync('danger');
if (dangerJS != null) {
dangerJSExecutable = dangerJS;
} else {
throw 'danger-js not found, please install danger-js, or run with --danger-js-path';
}
}
final _shell = shell ?? Shell(verbose: false);
final dangerJSHelpResult =
await _shell.runExecutableArguments(dangerJSExecutable, ['--help']);
final helpResult = dangerJSHelpResult.stdout.toString().trim();
if (!helpResult.contains(r'danger.systems/js')) {
throw 'Your danger is not JS version, You need to uninstall danger ruby, or using --danger-js-path instead';
}
return DangerJSMetadata(executable: dangerJSExecutable);
}