feat: ignore hidden files; fix some issue.

master
DebuggerX 4 years ago
parent 56d7dd7050
commit d1a859e9f6

@ -1,4 +1,5 @@
import 'dart:io';
import 'path_utils.dart';
import 'parse_arguments.dart';
import 'expressions/expressions.dart';
import 'flavors.dart';
@ -66,14 +67,17 @@ List<ReplaceOperation> operations = [];
List<ReplaceOperation> tempOperations = [];
List<ReplaceOperation> currentTempOperations = [];
final _commentReg = RegExp(' +\/\/');
final _commentReg = RegExp(' *\/\/');
var lastIndent = -1;
void walkPath(FileSystemEntity path) {
var stat = path.statSync();
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 &&
BLACK_FILE_EXT.indexWhere((ele) => path.path.endsWith(ele)) < 0) {
file = File(path.path);
@ -183,7 +187,8 @@ void walkPath(FileSystemEntity path) {
lines[operation.lineNumber - 1].replaceFirst('// ', '');
});
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");
} else {
file!.renameSync(path.path + '.bak');

@ -30,12 +30,15 @@ if [[ ! -x "$DART_EXE" ]]; then
echo "Can't find dart executable file !"
fi
${DART_EXE} "$SCRIPT_DIR"/bin/pre_script.dart "$@"
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} ./.hooks/pre_script.dart "$@"
${DART_EXE} ./pre_script.dart "$@"
fi
if [[ -f "./.hooks/pre_script.sh" ]]; then
@ -46,9 +49,7 @@ if [[ -f "./pre_script.sh" ]]; then
./pre_script.sh "$@"
fi
${DART_EXE} "$SCRIPT_DIR"/bin/pre_script.dart "$@"
if [[ "$JUST_REPLACE" == 0 ]]; then
flutter pub get
flutter ${ARGS[*]}

Loading…
Cancel
Save