mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-13 07:55:18 +00:00
cd: use dio in cli as well
This commit is contained in:
parent
b2d9e64758
commit
e1786989ff
@ -2,13 +2,19 @@ import 'dart:io';
|
|||||||
|
|
||||||
import 'package:args/command_runner.dart';
|
import 'package:args/command_runner.dart';
|
||||||
import 'package:collection/collection.dart';
|
import 'package:collection/collection.dart';
|
||||||
import 'package:http/http.dart';
|
import 'package:dio/dio.dart';
|
||||||
import 'package:html/parser.dart';
|
import 'package:html/parser.dart';
|
||||||
import 'package:path/path.dart';
|
import 'package:path/path.dart';
|
||||||
import 'package:pub_api_client/pub_api_client.dart';
|
import 'package:pub_api_client/pub_api_client.dart';
|
||||||
import 'package:pubspec_parse/pubspec_parse.dart';
|
import 'package:pubspec_parse/pubspec_parse.dart';
|
||||||
|
|
||||||
class CreditsCommand extends Command {
|
class CreditsCommand extends Command {
|
||||||
|
final dio = Dio(
|
||||||
|
BaseOptions(
|
||||||
|
responseType: ResponseType.plain,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get description => "Generate credits for used Library's authors";
|
String get description => "Generate credits for used Library's authors";
|
||||||
|
|
||||||
@ -66,11 +72,11 @@ class CreditsCommand extends Command {
|
|||||||
final gitPubspecs = await Future.wait(
|
final gitPubspecs = await Future.wait(
|
||||||
gitDeps.map(
|
gitDeps.map(
|
||||||
(d) {
|
(d) {
|
||||||
Pubspec parser(res) {
|
Pubspec parser(Response res) {
|
||||||
try {
|
try {
|
||||||
return Pubspec.parse(res.body);
|
return Pubspec.parse(res.data);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
final document = parse(res.body);
|
final document = parse(res.data);
|
||||||
final pre = document.querySelector('pre');
|
final pre = document.querySelector('pre');
|
||||||
if (pre == null) {
|
if (pre == null) {
|
||||||
stdout.writeln(d.toString());
|
stdout.writeln(d.toString());
|
||||||
@ -80,8 +86,9 @@ class CreditsCommand extends Command {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return get(Uri.parse(d.value)).then(parser).catchError(
|
return dio.get(d.value).then(parser).catchError(
|
||||||
(_) => get(Uri.parse(d.value.replaceFirst('/main', '/master')))
|
(_) => dio
|
||||||
|
.get(d.value.replaceFirst('/main', '/master'))
|
||||||
.then(parser),
|
.then(parser),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user