@@ -3,50 +3,47 @@ import 'dart:io';
3
3
import 'package:yaml/yaml.dart' ;
4
4
import 'package:io/ansi.dart' ;
5
5
6
+ import 'temp.dart' ;
7
+
6
8
main (List <String > arguments) {
7
- Platform .environment.forEach ((k,v)=> print ('$k $v ' ));
9
+ // Platform.environment.forEach((k,v)=>print('$k $v'));
8
10
// 执行命令
9
11
// Process.run(executable, arguments);
10
12
File pubspec = File ("./pubspec.yaml" );
11
13
var pubspecDoc = loadYaml (pubspec.readAsStringSync ());
12
- List excludes;
13
- if (pubspecDoc['flutter_icons' ] != null &&
14
- pubspecDoc['flutter_icons' ]['excludes' ] != null ) {
15
- excludes = pubspecDoc['flutter_icons' ]['excludes' ];
16
- File packages = File ('./.packages' );
17
- if (! packages.existsSync ()) {
18
- print (yellow.wrap ("${DateTime .now ()}: Get the dependencies first" ));
19
- return ;
20
- }
21
- List <String > lines = packages.readAsLinesSync ();
22
- // flutter_icons:file:///Users/makisu/development/flutter/.pub-cache/hosted/pub.flutter-io.cn/flutter_icons-1.0.0+1/lib/
23
- var flutterIconPath;
24
- for (var i = 0 ; i < lines.length; i++ ) {
25
- if (lines[i].contains ("flutter_icons" )) {
26
- flutterIconPath = lines[i]
27
- .replaceAll ("flutter_icons:file://" , "" )
28
- .replaceAll ("/lib/" , "" );
29
- break ;
30
- }
31
- }
32
- if (flutterIconPath == null ) {
33
- print (yellow.wrap ("${DateTime .now ()}: Get the flutter_icons dependency first" ));
34
- return ;
14
+ File packages = File ('./.packages' );
15
+ if (! packages.existsSync ()) {
16
+ print (yellow.wrap ("${DateTime .now ()}: Get the dependencies first" ));
17
+ return ;
18
+ }
19
+ List <String > lines = packages.readAsLinesSync ();
20
+ // flutter_icons:file:///Users/makisu/development/flutter/.pub-cache/hosted/pub.flutter-io.cn/flutter_icons-1.0.0+1/lib/
21
+ var flutterIconPath;
22
+ for (var i = 0 ; i < lines.length; i++ ) {
23
+ if (lines[i].contains ("flutter_icons" )) {
24
+ flutterIconPath = lines[i]
25
+ .replaceAll ("flutter_icons:file://${Platform .isWindows ?'/' :'' }" , "" )
26
+ .replaceAll ("/lib/" , "" );
27
+ break ;
35
28
}
36
- File flutterIconsFile = File (flutterIconPath + '/pubspec.yaml' );
37
- var iconsDoc = loadYaml (flutterIconsFile.readAsStringSync ());
38
- Map iconMap = Map .of (iconsDoc);
39
- Map flutter = Map .of (iconMap['flutter' ]);
40
- Map environment = Map .of (iconMap['environment' ]);
41
- environment["sdk" ] = "\" ${environment ['sdk' ]}\" " ;
42
- List fonts = List .of (flutter['fonts' ]);
43
- fonts.retainWhere ((font)=> ! excludes.contains (font['family' ]));
44
- flutter['fonts' ] = fonts;
45
- iconMap['flutter' ] = flutter;
46
- iconMap['environment' ] = environment;
47
- print (iconMap['environment' ]['sdk' ]);
48
- // flutterIconsFile.writeAsStringSync(iconMap.toString());
49
29
}
30
+ if (flutterIconPath == null ) {
31
+ print (yellow
32
+ .wrap ("${DateTime .now ()}: Get the flutter_icons dependency first" ));
33
+ return ;
34
+ }
35
+ File flutterIconsFile = File (flutterIconPath + '/pubspec.yaml' );
36
+ List includes;
37
+ String yamlString = tempYaml;
38
+ if (pubspecDoc['flutter_icons' ] != null &&
39
+ pubspecDoc['flutter_icons' ]['includes' ] != null ) {
40
+ includes = pubspecDoc['flutter_icons' ]['includes' ];
41
+ includes.forEach ((key){
42
+ yamlString += fontsMap[key];
43
+ });
44
+ }else {
45
+ yamlString += allFonts;
46
+ }
47
+ flutterIconsFile.writeAsStringSync (yamlString);
50
48
print (green.wrap ("${DateTime .now ()}: Finish the work" ));
51
-
52
49
}
0 commit comments