Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
devoncarew committed Nov 16, 2023
1 parent 1d62b47 commit a882404
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 16 deletions.
24 changes: 9 additions & 15 deletions pkgs/dart_services/lib/src/sdk.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import 'dart:io';

import 'package:path/path.dart' as path;

const stableChannel = 'stable';

class Sdk {
/// The path to the Flutter binaries.
late final String _flutterBinPath;
Expand Down Expand Up @@ -76,7 +74,7 @@ class Sdk {
flutterVersion = versions['flutterVersion'] as String;
engineVersion = versions['engineRevision'] as String;

// Report the 'master' channel to 'main';
// Report the 'master' channel as 'main';
final tempChannel = versions['channel'] as String;
channel = tempChannel == 'master' ? 'main' : tempChannel;
}
Expand All @@ -94,26 +92,22 @@ class Sdk {
// analytics disclaimer).

try {
final str = Process.runSync(
return jsonDecode(Process.runSync(
flutterToolPath,
['--version', '--machine'],
workingDirectory: sdkPath,
).stdout.toString().trim();
return jsonDecode(str) as Map<String, dynamic>;
).stdout.toString().trim()) as Map<String, dynamic>;
} on FormatException {
final str = Process.runSync(
return jsonDecode(Process.runSync(
flutterToolPath,
['--version', '--machine'],
workingDirectory: sdkPath,
).stdout.toString().trim();
return jsonDecode(str) as Map<String, dynamic>;
).stdout.toString().trim()) as Map<String, dynamic>;
}
}

static String _readVersionFile(String filePath) =>
_readFile(path.join(filePath, 'version'));
static String _readVersionFile(String filePath) {
final file = File(path.join(filePath, 'version'));
return file.readAsStringSync().trim();
}
}

const channels = ['stable', 'beta', 'main'];

String _readFile(String filePath) => File(filePath).readAsStringSync().trim();
3 changes: 2 additions & 1 deletion pkgs/dart_services/test/flutter_analysis_server_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import 'package:dart_services/src/sdk.dart';
import 'package:dart_services/src/server_cache.dart';
import 'package:test/test.dart';

final channel = Platform.environment['FLUTTER_CHANNEL'] ?? stableChannel;
final channel = Platform.environment['FLUTTER_CHANNEL'] ?? 'stable';

void main() => defineTests();

void defineTests() {
Expand Down

0 comments on commit a882404

Please sign in to comment.