Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions lib/src/services/pubspec_service.dart
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import 'dart:io';

import 'package:pubspec_yaml/pubspec_yaml.dart';
import 'package:yaml/yaml.dart';

/// Provides functionality to interact with the pubspec in the current project
class PubspecService {
late PubspecYaml pubspecYaml;
late YamlMap pubspecYaml;

/// Reads the pubpec and caches the value locally
/// Reads the pubspec and caches the value locally
Future<void> initialise({String? workingDirectory}) async {
final bool hasWorkingDirectory = workingDirectory != null;
// stdout.writeln('PubspecService - initialise from pubspec.yaml');
final pubspecYamlContent = await File(
'${hasWorkingDirectory ? '$workingDirectory/' : ''}pubspec.yaml')
.readAsString();
pubspecYaml = pubspecYamlContent.toPubspecYaml();
final pubspecYamlContent =
await File('${hasWorkingDirectory ? '$workingDirectory/' : ''}pubspec.yaml').readAsString();

pubspecYaml = loadYaml(pubspecYamlContent) as YamlMap;
// stdout.writeln('PubspecService - initialise complete');
}

String get getPackageName => pubspecYaml.name;
String get getPackageName => pubspecYaml['name'];
}
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ dependencies:
mockito: ^5.4.3
mustache_template: ^2.0.0
path: ^1.8.1
pubspec_yaml: ^3.1.0
yaml: ^3.1.3
recase: ^4.0.0
json_annotation: ^4.8.1
ansicolor: ^2.0.2
Expand Down