Skip to content

Commit 851ab99

Browse files
authored
Fix: setup.dart failed to run under Linux (#40)
* Fix: setup.dart failed to run under Linux webcryptoRoot.resolve('src') did not get evaluated to `$PUB_CACHE/webcrypto-x.y.z/src`, but just to `$PUB_CACHE/src`. This broke `flutter pub run webcrypto:setup` at the very least on Linux, but probably on more systems as well. Replacing the URI.resolve approach to a simple string concatenation fixes the bug. * Avoid potential doubled file seperators * joinPaths -> _joinPaths
1 parent 24536e3 commit 851ab99

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

bin/setup.dart

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ void main() async {
6363
'cmake',
6464
[
6565
'-S',
66-
webcryptoRoot.resolve('src').toFilePath(),
66+
Directory(_joinPaths(webcryptoRoot.toFilePath(), 'src'))
67+
.path,
6768
'-B',
6869
root.resolve('.dart_tool/webcrypto').toFilePath(),
6970
],
@@ -98,3 +99,11 @@ void main() async {
9899
print('This is only necessary for using package:webcrypto in unit tests');
99100
print('and scripts, not for usage in applications.');
100101
}
102+
103+
/// Join paths without duplicate path separators.
104+
String _joinPaths(String prefix, String suffix) {
105+
if (!prefix.endsWith(Platform.pathSeparator)) {
106+
prefix += Platform.pathSeparator;
107+
}
108+
return prefix + suffix;
109+
}

0 commit comments

Comments
 (0)