Skip to content

Commit

Permalink
fix(dotenv): When the repair encounters the system and directory, the…
Browse files Browse the repository at this point in the history
… search will continue infinitely.
  • Loading branch information
Seven Du committed Jun 6, 2024
1 parent da4f0ad commit 4a75cc5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
To install RC v0.3.1 with command:

```bash
dart pub add orm:0.3.1
dart pub add orm:^0.3.1
```

Or update your `pubspec.yaml` file:
Expand Down
9 changes: 9 additions & 0 deletions lib/src/loaders/dotenv/_find_project_directory.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Directory? _nestFindPubspecDirectory(Directory directory, bool shouldWarn) {
try {
final pubspec = File(path.join(directory.path, 'pubspec.yaml'));
if (pubspec.existsSync()) return directory;
if (_isOsRoot(directory)) return null;

return _nestFindPubspecDirectory(directory.parent, shouldWarn);
} catch (e) {
Expand All @@ -21,3 +22,11 @@ Directory? _nestFindPubspecDirectory(Directory directory, bool shouldWarn) {
return null;
}
}

bool _isOsRoot(Directory directory) {
if (Platform.isWindows) {
return directory.path.endsWith(':\\');
}

return path.relative(directory.path, from: '/') == '.';
}

0 comments on commit 4a75cc5

Please sign in to comment.