Skip to content

Commit d3909a4

Browse files
authored
Fix windows path resolving (#67)
1 parent 77cf078 commit d3909a4

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

pkgs/cli_config/lib/src/config.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -477,10 +477,11 @@ class Config {
477477
required core.bool resolveUri,
478478
required Uri? baseUri,
479479
}) {
480+
final uri = Source.fileSystemPathToUri(path);
480481
if (resolveUri && baseUri != null) {
481-
return baseUri.resolve(path);
482+
return baseUri.resolveUri(uri);
482483
}
483-
return Source.fileSystemPathToUri(path);
484+
return uri;
484485
}
485486

486487
/// Lookup a list of paths in this config.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
@TestOn('windows')
6+
library;
7+
8+
import 'package:cli_config/cli_config.dart';
9+
import 'package:test/test.dart';
10+
11+
void main() {
12+
test('path resolving windows', () {
13+
const path = 'C:\\foo\\bar\\';
14+
final workingDirectory = Uri.parse('file:///C:/baz/baf/');
15+
16+
final config = Config(
17+
commandLineDefines: ['key=$path'],
18+
workingDirectory: workingDirectory,
19+
);
20+
final value = config.path('key', resolveUri: true);
21+
expect(value.toFilePath(), path);
22+
});
23+
}

0 commit comments

Comments
 (0)