-
Notifications
You must be signed in to change notification settings - Fork 350
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support --linefeed in Dart and Node #153
Conversation
Like with |
Done! Removed |
Please also remove it from the command-line interface. |
Done. |
lib/src/node.dart
Outdated
@@ -41,8 +41,11 @@ void _render( | |||
var indentWidth = indentWidthValue is int | |||
? indentWidthValue | |||
: int.parse(indentWidthValue.toString()); | |||
var linefeed = parseLineFeed(options.linefeed); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should consistently capitalize lineFeed
, at least in places where we it doesn't need to be identical to the JS API. I think capitalizing "feed" is more correct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
lib/src/render.dart
Outdated
useSpaces: useSpaces, indentWidth: indentWidth, linefeed: linefeed); | ||
} | ||
|
||
LineFeed parseLineFeed(String str) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like this should be a private method in node.dart.
Also, please document it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
lib/src/render.dart
Outdated
case 'lfcr': | ||
return LineFeed.LFCR; | ||
break; | ||
case 'lf': |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line probably isn't necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
lib/src/render.dart
Outdated
@@ -17,7 +16,8 @@ String render(String path, | |||
{bool color: false, | |||
SyncPackageResolver packageResolver, | |||
bool useSpaces: true, | |||
int indentWidth: 2}) { | |||
int indentWidth: 2, | |||
LineFeed linefeed: LineFeed.LF}) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally we avoid providing default argument values for non-boolean arguments, since it makes it impossible to explicitly say "use the default value". You can just use ??
in the method body instead.
Same goes for indentWidth
, now that I think of it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. and Done for indentWidth
.
lib/src/visitor/serialize.dart
Outdated
@@ -19,6 +19,15 @@ import 'interface/css.dart'; | |||
import 'interface/selector.dart'; | |||
import 'interface/value.dart'; | |||
|
|||
enum LineFeed { CR, CRLF, LF, LFCR } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Official Dart enums suck 😝. If you use a custom class, you can just add the text as a field.
Also, I believe these should be all lowercase.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They do
lib/src/visitor/serialize.dart
Outdated
@@ -94,16 +105,20 @@ class _SerializeCssVisitor | |||
/// The number of spaces or tabs to be used for indentation. | |||
final int _indentWidth; | |||
|
|||
final String _linefeed; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please document this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Thanks Sam! |
* main: (162 commits) Move source and test files to namespaced subdirectories Update Dart Sass version and release Update Dart Sass version and release Update Dart Sass version and release Update Dart Sass version and release Update Dart Sass version and release Update Dart Sass version and release Revert "Remove workaround for dart-lang/setup-dart#59 (sass#151)" (sass#153) Update Dart Sass version and release Update Dart Sass version and release Remove workaround for dart-lang/setup-dart#59 (sass#151) Update Dart Sass version and release Update Dart Sass version and release Fix qemu releases (sass#149) Update Dart Sass version and release Bump sass_api from 4.2.1 to 5.0.0 (sass#143) Bump meta from 1.8.0 to 1.9.0 (sass#144) Bump grinder from 0.9.2 to 0.9.3 (sass#145) Add missing setup-dart step in qemu release (sass#147) Use buf instead of protoc to compile protobufs (sass#146) ...
Addresses part of #8
If someone passes in something other than
cr
,crlf
,lf
,lfcr
, it defaults oflf
, like node-sass.I'm happy to move
parseLineFeed
andenum LineFeed
to... other files, open to suggestions.I'm also happy to add tests, but
emitsInOrder
or whatever Stream, is not letting me see the line endings...But here's a cmdline test, with the newlines marked with
cat -e
: