Skip to content

[flutter_tools] tool exit from flutter create when provided just a drive letter #106451

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

Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
allow regex pattern to cover lower-case chars, add unit tests
  • Loading branch information
christopherfujino committed Jun 24, 2022
commit 8cbf2de6528b624ab1deb22a6c6d59df3253e4d6
5 changes: 3 additions & 2 deletions packages/flutter_tools/lib/src/commands/create_base.dart
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,15 @@ abstract class CreateBase extends FlutterCommand {
/// `dart:io` does not recognize strings matching this pattern as absolute
/// paths, as they have no top level back-slash; however, users often specify
/// this
static final RegExp _kWindowsDrivePattern = RegExp(r'^[A-Z]:$');
@visibleForTesting
static final RegExp kWindowsDrivePattern = RegExp(r'^[a-zA-Z]:$');

/// The output directory of the command.
@protected
@visibleForTesting
Directory get projectDir {
final String argProjectDir = argResults!.rest.first;
if (globals.platform.isWindows && _kWindowsDrivePattern.hasMatch(argProjectDir)) {
if (globals.platform.isWindows && kWindowsDrivePattern.hasMatch(argProjectDir)) {
throwToolExit(
'You attempted to create a flutter project at the path "$argProjectDir", which is the name of a drive. This '
'is usually a mistake--you probably want to specify a containing directory, like "$argProjectDir\\app_name". '
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,13 @@ void main() {

expect(isValidPackageName('Foo_bar'), false);
});

test('kWindowsDrivePattern', () {
expect(CreateBase.kWindowsDrivePattern.hasMatch(r'D:\'), isFalse);
expect(CreateBase.kWindowsDrivePattern.hasMatch(r'z:\'), isFalse);
expect(CreateBase.kWindowsDrivePattern.hasMatch(r'\d:'), isFalse);
expect(CreateBase.kWindowsDrivePattern.hasMatch(r'ef:'), isFalse);
expect(CreateBase.kWindowsDrivePattern.hasMatch(r'D:'), isTrue);
expect(CreateBase.kWindowsDrivePattern.hasMatch(r'c:'), isTrue);
});
}
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy