Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change to be independent of the path package #139

Merged
merged 5 commits into from
Jan 7, 2025
Merged
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
6 changes: 6 additions & 0 deletions packages/yumemi_lints/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ Examples of version updates are as follows:
> [!NOTE]
> Changes to `tools/update_lint_rules` don't affect versioning.

## 2.2.1

### Improvements

- Changed to be independent of the `path` package.

## 2.2.0

### Features
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import 'dart:io';
import 'dart:isolate';

import 'package:meta/meta.dart';
import 'package:path/path.dart' as path;
import 'package:pub_semver/pub_semver.dart';
import 'package:yaml/yaml.dart';
import 'package:yumemi_lints/src/models/exceptions.dart';
Expand Down Expand Up @@ -61,12 +60,11 @@ class UpdateCommandService {

File _getPubspecFile() {
final pubspecFile = File(
path.join(
[
Directory.current.path,
'pubspec.yaml',
),
].join(_separator),
);

if (!pubspecFile.existsSync()) {
throw Exception(
'The pubspec.yaml file could not be found in the current directory. '
Expand Down Expand Up @@ -160,16 +158,16 @@ class UpdateCommandService {
);
throw const CompatibleVersionException();
}

// If higher than the oldest supported version and lower than the latest
// supported version, but does not match any of the supported versions,
// print an error message and exit with an error.
printMessage(
'The version of ${projectType.formalName} $specifiedVersion specified '
'in pubspec.yaml does not exist. Please specify the version '
'that exists.',
);
throw const CompatibleVersionException();
'The version of ${projectType.formalName} $specifiedVersion specified '
'in pubspec.yaml does not exist. Please specify the version '
'that exists.',
);
throw const CompatibleVersionException();
}

@visibleForTesting
Expand Down Expand Up @@ -232,7 +230,10 @@ class UpdateCommandService {

void _updateAnalysisOptionsFile(String includeLine) {
final analysisOptionsFile = File(
path.join(Directory.current.path, 'analysis_options.yaml'),
[
Directory.current.path,
'analysis_options.yaml',
].join(_separator),
);
if (!analysisOptionsFile.existsSync()) {
// Create analysis_options.yaml if it does not exist
Expand Down Expand Up @@ -280,6 +281,23 @@ extension _ProjectTypeFormalName on ProjectType {

extension _FileSystemEntityName on FileSystemEntity {
String get name {
return this.path.split('/').last;
return path.split('/').last;
}
}

bool get _isWindowsStyle {
if (Uri.base.scheme != 'file') {
return false;
}
if (!Uri.base.path.endsWith('/')) {
return false;
}
return Uri(path: 'a/b').toFilePath() == r'a\b';
}

String get _separator {
if (_isWindowsStyle) {
return r'\';
}
return '/';
}
1 change: 0 additions & 1 deletion packages/yumemi_lints/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ dependencies:
args: ^2.3.1
file: ^6.1.4
meta: ^1.7.0
path: ^1.8.1
pub_semver: ^2.1.4
yaml: ^3.1.1

Expand Down
Loading