Skip to content

Commit 955a339

Browse files
authored
Use "flutter[.bat]" instead of "pub[.bat]" for flutter packages (#59, #45) (#318)
Use "flutter[.bat]" instead of "pub[.bat]" for flutter packages (#59, #45)
1 parent e2c85c2 commit 955a339

File tree

3 files changed

+49
-7
lines changed

3 files changed

+49
-7
lines changed

mono_repo/lib/src/ci_test_script.dart

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,32 @@ function $commandName() {
1616
fi
1717
}''';
1818

19+
String _dartCommandContentPub(String commandName) => '''
20+
# When it is a flutter repo (check the pubspec.yaml for "sdk: flutter")
21+
# then "flutter" is called instead of "pub".
22+
# This assumes that the Flutter SDK has been installed in a previous step.
23+
function $commandName() {
24+
if grep -Fq "sdk: flutter" "\${PWD}/pubspec.yaml"; then
25+
if [[ \$TRAVIS_OS_NAME == "windows" ]]; then
26+
command flutter.bat pub "\$@"
27+
else
28+
command flutter pub "\$@"
29+
fi
30+
else
31+
if [[ \$TRAVIS_OS_NAME == "windows" ]]; then
32+
command pub.bat "\$@"
33+
else
34+
command pub "\$@"
35+
fi
36+
fi
37+
}''';
38+
1939
final bashScriptHeader = '''
2040
#!/bin/bash
2141
$createdWith
2242
2343
# Support built in commands on windows out of the box.
24-
${_dartCommandContent('pub')}
44+
${_dartCommandContentPub('pub')}
2545
${_dartCommandContent('dartfmt')}
2646
${_dartCommandContent('dartanalyzer')}''';
2747

mono_repo/test/script_integration_outputs/readme_ci.txt

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,22 @@
22
# Created with package:mono_repo v1.2.3
33

44
# Support built in commands on windows out of the box.
5+
# When it is a flutter repo (check the pubspec.yaml for "sdk: flutter")
6+
# then "flutter" is called instead of "pub".
7+
# This assumes that the Flutter SDK has been installed in a previous step.
58
function pub() {
6-
if [[ $TRAVIS_OS_NAME == "windows" ]]; then
7-
command pub.bat "$@"
9+
if grep -Fq "sdk: flutter" "${PWD}/pubspec.yaml"; then
10+
if [[ $TRAVIS_OS_NAME == "windows" ]]; then
11+
command flutter.bat pub "$@"
12+
else
13+
command flutter pub "$@"
14+
fi
815
else
9-
command pub "$@"
16+
if [[ $TRAVIS_OS_NAME == "windows" ]]; then
17+
command pub.bat "$@"
18+
else
19+
command pub "$@"
20+
fi
1021
fi
1122
}
1223
function dartfmt() {

tool/ci.sh

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,22 @@
22
# Created with package:mono_repo v4.0.0-dev
33

44
# Support built in commands on windows out of the box.
5+
# When it is a flutter repo (check the pubspec.yaml for "sdk: flutter")
6+
# then "flutter" is called instead of "pub".
7+
# This assumes that the Flutter SDK has been installed in a previous step.
58
function pub() {
6-
if [[ $TRAVIS_OS_NAME == "windows" ]]; then
7-
command pub.bat "$@"
9+
if grep -Fq "sdk: flutter" "${PWD}/pubspec.yaml"; then
10+
if [[ $TRAVIS_OS_NAME == "windows" ]]; then
11+
command flutter.bat pub "$@"
12+
else
13+
command flutter pub "$@"
14+
fi
815
else
9-
command pub "$@"
16+
if [[ $TRAVIS_OS_NAME == "windows" ]]; then
17+
command pub.bat "$@"
18+
else
19+
command pub "$@"
20+
fi
1021
fi
1122
}
1223
function dartfmt() {

0 commit comments

Comments
 (0)