@@ -33,19 +33,23 @@ renameApp() async {
33
33
34
34
Logger .newLine ();
35
35
36
- Logger .info ("Let's change all in lib !" );
37
- await _changeAllImportsIn ("lib" , config);
36
+ if (config.oldDartPackageName != config.newDartPackageName) {
37
+ Logger .info ("Let's change all in lib !" );
38
+ _changeAllImportsIn ("lib" , config);
38
39
39
- Logger .info ("Let's change all in tests !" );
40
- await _changeAllImportsIn ("test" , config);
40
+ Logger .info ("Let's change all in tests !" );
41
+ _changeAllImportsIn ("test" , config);
42
+ }
41
43
42
- await changeAndroidPackageName (config);
44
+ if (config.oldAndroidPackageName != config.newAndroidPackageName) {
45
+ await changeAndroidPackageName (config);
46
+ }
43
47
44
48
final List <RequiredChange > contentChanges = getFilesToModifyContent (config);
45
- await _applyContentChanges (contentChanges);
49
+ _applyContentChanges (contentChanges);
46
50
47
51
final List <RequiredChange > nameChanges = getFilesToModifyName (config);
48
- await _applyNameChanges (nameChanges);
52
+ _applyNameChanges (nameChanges);
49
53
50
54
final shell = Shell ();
51
55
@@ -55,17 +59,16 @@ renameApp() async {
55
59
Logger .error (error.message);
56
60
return ;
57
61
}
58
- print ("ERROR : $error " );
59
62
}
60
63
}
61
64
62
- _changeAllImportsIn (String directoryPath, Config config) async {
65
+ _changeAllImportsIn (String directoryPath, Config config) {
63
66
final Directory directory = Directory (directoryPath);
64
67
if (directory.existsSync ()) {
65
68
final List <FileSystemEntity > files = directory.listSync (recursive: true );
66
- await Future .forEach (files, (FileSystemEntity fileSystemEntity) async {
69
+ files .forEach ((FileSystemEntity fileSystemEntity) {
67
70
if (fileSystemEntity is File ) {
68
- await _changeContentInFile (
71
+ _changeContentInFile (
69
72
fileSystemEntity.path,
70
73
RegExp (config.oldDartPackageName),
71
74
config.newDartPackageName,
@@ -77,24 +80,24 @@ _changeAllImportsIn(String directoryPath, Config config) async {
77
80
}
78
81
}
79
82
80
- _applyNameChanges (List <RequiredChange > requiredChanges) async {
81
- return await Future .forEach (requiredChanges, (RequiredChange change) async {
83
+ _applyNameChanges (List <RequiredChange > requiredChanges) {
84
+ requiredChanges .forEach ((RequiredChange change) {
82
85
for (final path in change.paths) {
83
- await _changeFileName (path, change.regexp, change.replacement);
86
+ _changeFileName (path, change.regexp, change.replacement);
84
87
}
85
88
});
86
89
}
87
90
88
- _applyContentChanges (List <RequiredChange > requiredChanges) async {
89
- return await Future .forEach (requiredChanges, (RequiredChange change) async {
91
+ _applyContentChanges (List <RequiredChange > requiredChanges) {
92
+ requiredChanges .forEach ((RequiredChange change) {
90
93
for (final path in change.paths) {
91
94
if (change.isDirectory) {
92
95
final Directory directory = Directory (path);
93
- Future . forEach ( directory.listSync (recursive: true ), ( FileSystemEntity entity) async {
94
- await _changeContentInFile (entity.path, change.regexp, change.replacement);
96
+ directory.listSync (recursive: true ). forEach (( FileSystemEntity entity) {
97
+ _changeContentInFile (entity.path, change.regexp, change.replacement);
95
98
});
96
99
} else {
97
- await _changeContentInFile (path, change.regexp, change.replacement);
100
+ _changeContentInFile (path, change.regexp, change.replacement);
98
101
}
99
102
}
100
103
});
@@ -105,9 +108,7 @@ _changeFileName(String filePath, RegExp regexp, String replacement) {
105
108
try {
106
109
final File file = File (filePath);
107
110
file.renameSync (filePath.replaceAll (regexp, replacement));
108
- } on FileSystemException {
109
- ///Logger.error("File $filePath does not exist on this project");
110
- }
111
+ } catch (error) {}
111
112
}
112
113
}
113
114
@@ -120,7 +121,5 @@ _changeContentInFile(String filePath, RegExp regexp, String replacement) {
120
121
file.writeAsStringSync (newContent);
121
122
Logger .info ("Changed file $filePath " );
122
123
}
123
- } on FileSystemException {
124
- ///Logger.error("File $filePath does not exist on this project");
125
- }
124
+ } catch (error) {}
126
125
}
0 commit comments