sass / migrator

Tool for migrating stylesheets to new Sass versions
MIT License
89 stars 11 forks source link

--remove-prefix without --migrate-deps can generate invalid member references #85

Closed nex3 closed 5 years ago

nex3 commented 5 years ago

If you remove a prefix without migrating dependencies, and the files you pass on the command line include the use of a prefixed member but not that member's definition, the uses will be migrated but the definition will not rendering those uses invalid. For example:

// input.scss
@import "a";
@debug $a-b;
// _a.scss
$a-b: c;

Running sass-migrator module --remove-prefix=a- input.scss will result in

// input.scss
@use "a";
@debug a.$b`
// _a.scss
$a-b: c;

It's probably best to just throw an error here and encourage users to re-run with either --migrate-deps or with _a.scss passed on the command line as well.

nex3 commented 5 years ago

Essentially the same issue exists when migrating only the usage of a pseudoprivate member as well.

coltanium13 commented 2 years ago

@nex3 does the --remove-prefix command not exist anymore? im using the latest sass-migrator ("^1.5.2"), and it says it does not exist. when i run sass-migrator --version, it also blows up...

PS C:\Users\coltong\source\repos\Ovations_v2\frontend\platform\src\styles> sass-migrator --version        
Unhandled exception:
Invalid argument (uri): Value must be a String or a Uri: null
#0      _parseUri (package:path/src/context.dart:1064:3)
#1      Context.fromUri (package:path/src/context.dart:985:44)
#2      fromUri (package:path/path.dart:420:32)
#3      _loadVersion (package:sass_migrator/src/runner.dart:141:16)
<asynchronous suspension>
#4      MigratorRunner.execute (package:sass_migrator/src/runner.dart:71:19)
<asynchronous suspension>
#5      main (file:///home/travis/build/sass/migrator/bin/sass_migrator.dart:16:20)
#6      _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:303:32)
#7      _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:172:12)
jathak commented 2 years ago

The --remove-prefix command style works. This looks like a (probably platform-specific) bug with argument parsing. Can you open a new issue for this and include the method by which you installed the migrator?

coltanium13 commented 2 years ago

@jathak i might have had a weird issue with the --remove-prefix, and cant get it to throw an error now.

however, the --version command blows up. Is this a known issue?

C:\source\repos\Ovations_v2\frontend\platform\src\styles>sass-migrator -h
Migrates stylesheets to new Sass versions.

Usage: sass_migrator <migrator> [options] <entrypoint.scss...>

Global options:
-h, --help                Print this usage information.
-I, --load-path=<PATH>    A path to use when resolving imports.
                          May be passed multiple times.

-d, --migrate-deps        Migrate dependencies in addition to entrypoints.
-n, --dry-run             Show which files would be migrated but make no changes.
-c, --[no-]color          Whether to use terminal colors for messages..
    --[no-]unicode        Whether to use Unicode characters for messages.
-v, --verbose             Print more information.
    --version             Print the version of the Sass migrator.

Available commands:
  help     Display help information for sass_migrator.
  module   Use the new module system.

Run "sass_migrator help <command>" for more information about a command.

See also https://sass-lang.com/documentation/cli/migrator

C:\source\repos\Ovations_v2\frontend\platform\src\styles>sass-migrator --version
Unhandled exception:
Invalid argument (uri): Value must be a String or a Uri: null
#0      _parseUri (package:path/src/context.dart:1064:3)
#1      Context.fromUri (package:path/src/context.dart:985:44)
#2      fromUri (package:path/path.dart:420:32)
#3      _loadVersion (package:sass_migrator/src/runner.dart:141:16)
<asynchronous suspension>
#4      MigratorRunner.execute (package:sass_migrator/src/runner.dart:71:19)
<asynchronous suspension>
#5      main (file:///home/travis/build/sass/migrator/bin/sass_migrator.dart:16:20)
#6      _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:303:32)
#7      _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:172:12)