Skip to content

Commit 93a8436

Browse files
authored
Merge pull request #34 from passsy/subfolder
2 parents 3fb7483 + e8317d8 commit 93a8436

File tree

3 files changed

+74
-2
lines changed

3 files changed

+74
-2
lines changed

install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ FLUTTER_SUBMODULE_NAME='.flutter'
5959
GIT_HOME=$(git rev-parse --show-toplevel)
6060

6161
# Check if submodule already exists (when updating flutter wrapper)
62-
HAS_SUBMODULE=$(git submodule | grep "\ ${FLUTTER_SUBMODULE_NAME}")
62+
HAS_SUBMODULE=$(git -C "${GIT_HOME}" submodule | grep "\ ${FLUTTER_SUBMODULE_NAME}")
6363
if [ -z "${HAS_SUBMODULE}" ]; then
6464
printf "adding '%s' submodule\n" "${FLUTTER_SUBMODULE_NAME}"
6565
UPDATED=false

test/test/install_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ void main() {
3939
late Directory appDir;
4040

4141
tearDownAll(() {
42-
// appDir.parent.deleteSync(recursive: true);
42+
appDir.parent.deleteSync(recursive: true);
4343
});
4444
setUpAll(() async {
4545
final dir =

test/test/update_test.dart

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
import 'package:cli_script/cli_script.dart';
2+
import 'package:file/file.dart';
3+
import 'package:file/local.dart';
4+
import 'package:test/test.dart';
5+
6+
import 'install_test.dart';
7+
8+
void main() {
9+
group('update', () {
10+
group("Update flutterw in git root", () {
11+
late Directory gitRootDir;
12+
late Directory appDir;
13+
14+
tearDownAll(() {
15+
appDir.parent.deleteSync(recursive: true);
16+
});
17+
setUpAll(() async {
18+
final dir =
19+
const LocalFileSystem().systemTempDirectory.createTempSync('root');
20+
gitRootDir = appDir = dir.childDirectory('myApp');
21+
assert(gitRootDir == appDir);
22+
23+
// create git in appDir
24+
appDir.createSync();
25+
await run("git init", workingDirectory: appDir.absolute.path);
26+
27+
await runInstallScript(
28+
appDir: appDir.absolute.path, gitRootDir: gitRootDir.absolute.path);
29+
});
30+
31+
test('updates flutterw', () async {
32+
final flutterw = appDir.childFile('flutterw');
33+
final content = flutterw.readAsStringSync();
34+
await runInstallScript(
35+
appDir: appDir.absolute.path, gitRootDir: gitRootDir.absolute.path);
36+
37+
final update = flutterw.readAsStringSync();
38+
expect(update, isNot(content));
39+
});
40+
});
41+
42+
group("update in subdir", () {
43+
late Directory gitRootDir;
44+
late Directory appDir;
45+
46+
tearDownAll(() {
47+
gitRootDir.deleteSync(recursive: true);
48+
});
49+
50+
setUpAll(() async {
51+
gitRootDir =
52+
const LocalFileSystem().systemTempDirectory.createTempSync('root');
53+
// git repo in root, flutterw in appDir
54+
appDir = gitRootDir.childDirectory('myApp')..createSync();
55+
56+
await run("git init", workingDirectory: gitRootDir.absolute.path);
57+
await runInstallScript(
58+
appDir: appDir.absolute.path, gitRootDir: gitRootDir.absolute.path);
59+
});
60+
61+
test('updates flutterw', () async {
62+
final flutterw = appDir.childFile('flutterw');
63+
final content = flutterw.readAsStringSync();
64+
await runInstallScript(
65+
appDir: appDir.absolute.path, gitRootDir: gitRootDir.absolute.path);
66+
67+
final update = flutterw.readAsStringSync();
68+
expect(update, isNot(content));
69+
});
70+
});
71+
});
72+
}

0 commit comments

Comments
 (0)