Skip to content

Commit b9c56e4

Browse files
authored
Support @forward rules with --migrate-deps (#299)
1 parent 36efb71 commit b9c56e4

7 files changed

Lines changed: 66 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 2.5.7
2+
3+
* Fix a bug where the `--migrate-deps` flag would not apply to dependencies
4+
via `@forward` rules.
5+
16
## 2.5.6
27

38
* No user-visible changes.

lib/src/migration_visitor.dart

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,16 @@ abstract class MigrationVisitor extends ScopedAstVisitor {
190190
}
191191
}
192192

193+
/// If [migrateDependencies] is enabled, this dependency will be
194+
/// migrated before continuing.
195+
@override
196+
visitForwardRule(ForwardRule node) {
197+
super.visitForwardRule(node);
198+
if (migrateDependencies) {
199+
visitDependency(node.url, node.span);
200+
}
201+
}
202+
193203
/// Asserts that [value] is not `null` and returns it.
194204
///
195205
/// This is used for fields that are set whenever the migrator is visiting

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: sass_migrator
2-
version: 2.5.6
2+
version: 2.5.7
33
description: A tool for running migrations on Sass files
44
homepage: https://github.com/sass/migrator
55

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
These tests are not specific to the `if-function` migrator, and instead designed
2+
to test the `--migrate-deps` flag.
3+
4+
When the `if-function` migrator is obsoleted and removed, these tests should
5+
be duplicated for a different migrator.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<==> arguments
2+
--migrate-deps
3+
4+
<==> input/entrypoint.scss
5+
@forward "library";
6+
7+
<==> input/_library.scss
8+
a {
9+
b: if(true, c, d);
10+
}
11+
12+
<==> output/_library.scss
13+
a {
14+
b: if(sass(true): c; else: d);
15+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<==> arguments
2+
--migrate-deps
3+
4+
<==> input/entrypoint.scss
5+
@import "library";
6+
7+
<==> input/_library.scss
8+
a {
9+
b: if(true, c, d);
10+
}
11+
12+
<==> output/_library.scss
13+
a {
14+
b: if(sass(true): c; else: d);
15+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<==> arguments
2+
--migrate-deps
3+
4+
<==> input/entrypoint.scss
5+
@use "library";
6+
7+
<==> input/_library.scss
8+
a {
9+
b: if(true, c, d);
10+
}
11+
12+
<==> output/_library.scss
13+
a {
14+
b: if(sass(true): c; else: d);
15+
}

0 commit comments

Comments
 (0)