Fix some bugs

master
DebuggerX 5 years ago
parent c5befd94cb
commit 5d84561447

@ -29,6 +29,7 @@ STATE state = STATE.none;
RegExp re = RegExp(r'// #\[(debug|release)?(?:\[(.*)\])?\]'); RegExp re = RegExp(r'// #\[(debug|release)?(?:\[(.*)\])?\]');
RegExp pathRe = RegExp(r'\[(debug|release)?(?:\[(.*)\])?\]'); RegExp pathRe = RegExp(r'\[(debug|release)?(?:\[(.*)\])?\]');
Match ma; Match ma;
bool modified = false;
void walkPath(FileSystemEntity path) { void walkPath(FileSystemEntity path) {
var stat = path.statSync(); var stat = path.statSync();
@ -53,10 +54,12 @@ void walkPath(FileSystemEntity path) {
// //
file = File(path.path); file = File(path.path);
sb.clear(); sb.clear();
modified = false;
try { try {
file.readAsLinesSync().forEach((line) { file.readAsLinesSync().forEach((line) {
ma = re.firstMatch(line); ma = re.firstMatch(line);
if (ma != null) { if (ma != null) {
modified = true;
mode = ma.group(1); mode = ma.group(1);
flavors = (ma.group(2) ?? '').split(' ').where((ele) => ele.trim() != '').toList(); flavors = (ma.group(2) ?? '').split(' ').where((ele) => ele.trim() != '').toList();
@ -70,6 +73,8 @@ void walkPath(FileSystemEntity path) {
// //
else if (state == STATE.caching || state == STATE.cached) { else if (state == STATE.caching || state == STATE.cached) {
state = STATE.replace; state = STATE.replace;
} else if (state == STATE.notMatch) {
state = STATE.none;
} }
} else { } else {
// //
@ -88,15 +93,18 @@ void walkPath(FileSystemEntity path) {
} }
} else { } else {
// nonelinesb // nonelinesb
if (state == STATE.none) if (state == STATE.none) {
sb.writeln(line); sb.writeln(line);
}
// //
else if (state == STATE.caching) tmp.writeln(line.replaceFirst('// ', '')); else if (state == STATE.caching) tmp.writeln(line.replaceFirst('// ', ''));
// //
} }
}); });
if (modified) {
file.renameSync(path.path + '.bak'); file.renameSync(path.path + '.bak');
File(path.path).writeAsStringSync(sb.toString(), flush: true); File(path.path).writeAsStringSync(sb.toString(), flush: true);
}
} catch (e) { } catch (e) {
if (!(e is FileSystemException)) { if (!(e is FileSystemException)) {
rethrow; rethrow;

@ -30,7 +30,7 @@ fi
${DART_EXE} "$SCRIPT_DIR"/bin/pre_script.dart "$@" ${DART_EXE} "$SCRIPT_DIR"/bin/pre_script.dart "$@"
#flutter "$@" flutter "$@"
${DART_EXE} "$SCRIPT_DIR"/bin/after_script.dart "$@" ${DART_EXE} "$SCRIPT_DIR"/bin/after_script.dart "$@"

Loading…
Cancel
Save