@@ -14,6 +14,7 @@ import 'package:sass/src/import_cache.dart';
14
14
15
15
import 'package:args/command_runner.dart' ;
16
16
import 'package:glob/glob.dart' ;
17
+ import 'package:glob/list_local_fs.dart' ;
17
18
import 'package:meta/meta.dart' ;
18
19
import 'package:path/path.dart' as p;
19
20
import 'package:sass_migrator/src/util/node_modules_importer.dart' ;
@@ -45,7 +46,7 @@ abstract class Migrator extends Command<Map<Uri, String>> {
45
46
"See also https://sass-lang.com/documentation/cli/migrator#$name " ;
46
47
47
48
/// If true, dependencies will be migrated in addition to the entrypoints.
48
- bool get migrateDependencies => globalResults['migrate-deps' ] as bool ;
49
+ bool get migrateDependencies => globalResults! ['migrate-deps' ] as bool ;
49
50
50
51
/// Map of missing dependency URLs to the spans that import/use them.
51
52
///
@@ -75,11 +76,12 @@ abstract class Migrator extends Command<Map<Uri, String>> {
75
76
Map <Uri , String > run () {
76
77
var allMigrated = < Uri , String > {};
77
78
var importer = FilesystemImporter ('.' );
78
- var importCache = ImportCache ([NodeModulesImporter ()],
79
- loadPaths: globalResults['load-path' ]);
79
+ var importCache = ImportCache (
80
+ importers: [NodeModulesImporter ()],
81
+ loadPaths: globalResults! ['load-path' ]);
80
82
81
83
var entrypoints = [
82
- for (var argument in argResults.rest)
84
+ for (var argument in argResults! .rest)
83
85
for (var entry in Glob (argument).listSync ())
84
86
if (entry is File ) entry.path
85
87
];
@@ -91,15 +93,14 @@ abstract class Migrator extends Command<Map<Uri, String>> {
91
93
}
92
94
93
95
var migrated = migrateFile (importCache, tuple.item2, tuple.item1);
94
- for (var file in migrated.keys) {
95
- if (allMigrated.containsKey (file) &&
96
- migrated[file] != allMigrated[file]) {
96
+ migrated.forEach ((file, contents) {
97
+ if (allMigrated.containsKey (file) && contents != allMigrated[file]) {
97
98
throw MigrationException (
98
99
"The migrator has found multiple possible migrations for $file , "
99
100
"depending on the context in which it's loaded." );
100
101
}
101
- allMigrated[file] = migrated[file] ;
102
- }
102
+ allMigrated[file] = contents ;
103
+ });
103
104
}
104
105
105
106
if (missingDependencies.isNotEmpty) _warnForMissingDependencies ();
@@ -114,7 +115,7 @@ abstract class Migrator extends Command<Map<Uri, String>> {
114
115
/// In verbose mode, this instead prints a full warning with the source span
115
116
/// for each missing dependency.
116
117
void _warnForMissingDependencies () {
117
- if (globalResults['verbose' ] as bool ) {
118
+ if (globalResults! ['verbose' ] as bool ) {
118
119
for (var uri in missingDependencies.keys) {
119
120
emitWarning ("Could not find Sass file at '${p .prettyUri (uri )}'." ,
120
121
missingDependencies[uri]);
@@ -123,11 +124,10 @@ abstract class Migrator extends Command<Map<Uri, String>> {
123
124
var count = missingDependencies.length;
124
125
emitWarning (
125
126
"$count dependenc${count == 1 ? 'y' : 'ies' } could not be found." );
126
- for (var uri in missingDependencies.keys) {
127
- var context = missingDependencies[uri];
128
- printStderr (' ${p .prettyUri (uri )} '
127
+ missingDependencies.forEach ((url, context) {
128
+ printStderr (' ${p .prettyUri (url )} '
129
129
'@${p .prettyUri (context .sourceUrl )}:${context .start .line + 1 }' );
130
- }
130
+ });
131
131
}
132
132
}
133
133
}
0 commit comments