Skip to content

Commit

Permalink
Properly migrate built-ins with underscores (#165)
Browse files Browse the repository at this point in the history
Fixes #138.
  • Loading branch information
jathak authored Oct 23, 2020
1 parent 694317a commit 9d4fb20
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 2 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 1.2.5

### Module Migrator

* The migrator now properly migrates built-in function calls with underscores
(e.g. `map_get`).

## 1.2.4

### Module Migrator
Expand Down
2 changes: 1 addition & 1 deletion lib/src/migrators/module/references.dart
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ class _ReferenceVisitor extends RecursiveAstVisitor {
for (var function in functions) {
if (_isCssCompatibilityOverload(function)) continue;
if (function.name.asPlain == null) continue;
var name = function.name.asPlain;
var name = function.name.asPlain.replaceAll('_', '-');
var module = builtInFunctionModules[name];
if (module != null) _sources[function] = BuiltInSource(module);
}
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: sass_migrator
version: 1.2.4
version: 1.2.5
description: A tool for running migrations on Sass files
author: Jennifer Thakar <[email protected]>
homepage: https://github.com/sass/migrator
Expand Down
12 changes: 12 additions & 0 deletions test/migrators/module/built_in_functions/underscores.hrx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<==> input/entrypoint.scss
$a: map_get((a: 1), a);
$b: str_length("hello");
$c: scale_color(blue, $lightness: -10%);

<==> output/entrypoint.scss
@use "sass:color";
@use "sass:map";
@use "sass:string";
$a: map.get((a: 1), a);
$b: string.length("hello");
$c: color.scale(blue, $lightness: -10%);

0 comments on commit 9d4fb20

Please sign in to comment.