feat: ignore hidden files; fix some issue.

This commit is contained in:
2021-09-06 14:08:48 +08:00
parent 56d7dd7050
commit d1a859e9f6
2 changed files with 25 additions and 19 deletions
+8 -3
View File
@@ -1,4 +1,5 @@
import 'dart:io'; import 'dart:io';
import 'path_utils.dart';
import 'parse_arguments.dart'; import 'parse_arguments.dart';
import 'expressions/expressions.dart'; import 'expressions/expressions.dart';
import 'flavors.dart'; import 'flavors.dart';
@@ -66,14 +67,17 @@ List<ReplaceOperation> operations = [];
List<ReplaceOperation> tempOperations = []; List<ReplaceOperation> tempOperations = [];
List<ReplaceOperation> currentTempOperations = []; List<ReplaceOperation> currentTempOperations = [];
final _commentReg = RegExp(' +\/\/'); final _commentReg = RegExp(' *\/\/');
var lastIndent = -1; var lastIndent = -1;
void walkPath(FileSystemEntity path) { void walkPath(FileSystemEntity path) {
var stat = path.statSync(); var stat = path.statSync();
if (stat.type == FileSystemEntityType.directory) { if (stat.type == FileSystemEntityType.directory) {
Directory(path.path).listSync().forEach(walkPath); Directory(path.path)
.listSync()
.where((f) => !PathUtils.baseName(f).startsWith('.'))
.forEach(walkPath);
} else if (stat.type == FileSystemEntityType.file && } else if (stat.type == FileSystemEntityType.file &&
BLACK_FILE_EXT.indexWhere((ele) => path.path.endsWith(ele)) < 0) { BLACK_FILE_EXT.indexWhere((ele) => path.path.endsWith(ele)) < 0) {
file = File(path.path); file = File(path.path);
@@ -183,7 +187,8 @@ void walkPath(FileSystemEntity path) {
lines[operation.lineNumber - 1].replaceFirst('// ', ''); lines[operation.lineNumber - 1].replaceFirst('// ', '');
}); });
file!.deleteSync(); file!.deleteSync();
File(path.path).writeAsStringSync(lines.join('\n'), flush: true); File(path.path)
.writeAsStringSync(lines.join('\n') + '\n', flush: true);
print("${file!.path} modified"); print("${file!.path} modified");
} else { } else {
file!.renameSync(path.path + '.bak'); file!.renameSync(path.path + '.bak');
+17 -16
View File
@@ -30,25 +30,26 @@ if [[ ! -x "$DART_EXE" ]]; then
echo "Can't find dart executable file !" echo "Can't find dart executable file !"
fi fi
if [[ -f "./.hooks/pre_script.dart" ]]; then
${DART_EXE} ./.hooks/pre_script.dart "$@"
fi
if [[ -f "./pre_script.dart" ]]; then
${DART_EXE} ./.hooks/pre_script.dart "$@"
fi
if [[ -f "./.hooks/pre_script.sh" ]]; then
./.hooks/pre_script.sh "$@"
fi
if [[ -f "./pre_script.sh" ]]; then
./pre_script.sh "$@"
fi
${DART_EXE} "$SCRIPT_DIR"/bin/pre_script.dart "$@" ${DART_EXE} "$SCRIPT_DIR"/bin/pre_script.dart "$@"
if [[ "$JUST_REPLACE" == 0 ]]; then if [[ "$JUST_REPLACE" == 0 ]]; then
if [[ -f "./.hooks/pre_script.dart" ]]; then
${DART_EXE} ./.hooks/pre_script.dart "$@"
fi
if [[ -f "./pre_script.dart" ]]; then
${DART_EXE} ./pre_script.dart "$@"
fi
if [[ -f "./.hooks/pre_script.sh" ]]; then
./.hooks/pre_script.sh "$@"
fi
if [[ -f "./pre_script.sh" ]]; then
./pre_script.sh "$@"
fi
flutter pub get
flutter ${ARGS[*]} flutter ${ARGS[*]}