|
|
@ -2,6 +2,19 @@ import 'dart:io';
|
|
|
|
import 'parse_arguments.dart';
|
|
|
|
import 'parse_arguments.dart';
|
|
|
|
import 'expressions/expressions.dart';
|
|
|
|
import 'expressions/expressions.dart';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const FLAVORS = [
|
|
|
|
|
|
|
|
'test',
|
|
|
|
|
|
|
|
'tw',
|
|
|
|
|
|
|
|
'cn',
|
|
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
final _ctx = {
|
|
|
|
|
|
|
|
'debug': 'debug',
|
|
|
|
|
|
|
|
'release': 'release',
|
|
|
|
|
|
|
|
'profile': 'profile',
|
|
|
|
|
|
|
|
'default': 'default',
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
String? exp;
|
|
|
|
String? exp;
|
|
|
|
late String mode;
|
|
|
|
late String mode;
|
|
|
|
late String flavor;
|
|
|
|
late String flavor;
|
|
|
@ -19,6 +32,13 @@ void main(List<String> arguments) {
|
|
|
|
mode = args.mode;
|
|
|
|
mode = args.mode;
|
|
|
|
flavor = args.flavor;
|
|
|
|
flavor = args.flavor;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_ctx.addEntries(FLAVORS.map((e) => MapEntry(e, e)));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_ctx.addAll({
|
|
|
|
|
|
|
|
'mode': mode,
|
|
|
|
|
|
|
|
'flavor': flavor,
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
var rootDir = Directory('./');
|
|
|
|
var rootDir = Directory('./');
|
|
|
|
rootDir.listSync().forEach(walkPath);
|
|
|
|
rootDir.listSync().forEach(walkPath);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -67,8 +87,7 @@ void walkPath(FileSystemEntity path) {
|
|
|
|
state = STATE.none;
|
|
|
|
state = STATE.none;
|
|
|
|
tmp.clear();
|
|
|
|
tmp.clear();
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
if (evaluator.eval(
|
|
|
|
if (evaluator.eval(Expression.parse(exp!), _ctx)) {
|
|
|
|
Expression.parse(exp!), {'mode': mode, 'flavor': flavor})) {
|
|
|
|
|
|
|
|
// 匹配到
|
|
|
|
// 匹配到
|
|
|
|
tmp.clear();
|
|
|
|
tmp.clear();
|
|
|
|
state = STATE.caching;
|
|
|
|
state = STATE.caching;
|
|
|
@ -90,7 +109,6 @@ void walkPath(FileSystemEntity path) {
|
|
|
|
if (modified) {
|
|
|
|
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);
|
|
|
|
print(sb.toString());
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
} catch (e) {
|
|
|
|
if (!(e is FileSystemException)) {
|
|
|
|
if (!(e is FileSystemException)) {
|
|
|
|