Skip to content

Commit

Permalink
Fix crash on Node (#185)
Browse files Browse the repository at this point in the history
  • Loading branch information
jathak authored Apr 30, 2021
1 parent b4fc3d4 commit ef02c63
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ jobs:
with: {node-version: "${{ matrix.node_version }}"}
- run: npm install
- run: dart pub run grinder pkg-npm-dev
- name: Run tests
run: dart pub run test -t node -r expanded

static_analysis:
name: Static analysis
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.3.9

* Fix crash when running on Node.

## 1.3.8

* No user-visible changes.
Expand Down
4 changes: 4 additions & 0 deletions lib/src/io/node.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
// license that can be found in the LICENSE file or at
// https://opensource.org/licenses/MIT.

import 'package:file/file.dart';
import 'package:js/js.dart';
import 'package:node_interop/node.dart';
import 'package:node_io/node_io.dart';

// Node seems to support ANSI escapes on all terminals.
//
Expand All @@ -15,3 +17,5 @@ import 'package:node_interop/node.dart';
external bool get supportsAnsiEscapes;

void printStderr(Object message) => process.stderr.write("$message\n");

FileSystem get fileSystem => nodeFileSystem;
6 changes: 6 additions & 0 deletions lib/src/io/vm.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

import 'dart:io';

import 'package:file/file.dart';
import 'package:file/local.dart';

/// Whether this process is connected to a terminal that supports ANSI escape
/// sequences.
bool get supportsAnsiEscapes {
Expand All @@ -19,3 +22,6 @@ bool get supportsAnsiEscapes {

/// Prints [message] to standard error, followed by a newline.
void printStderr(Object message) => stderr.writeln(message);

/// The local filesystem.
FileSystem get fileSystem => const LocalFileSystem();
3 changes: 1 addition & 2 deletions lib/src/migrator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import 'package:sass/src/import_cache.dart';

import 'package:args/command_runner.dart';
import 'package:glob/glob.dart';
import 'package:glob/list_local_fs.dart';
import 'package:meta/meta.dart';
import 'package:path/path.dart' as p;
import 'package:sass_migrator/src/util/node_modules_importer.dart';
Expand Down Expand Up @@ -82,7 +81,7 @@ abstract class Migrator extends Command<Map<Uri, String>> {

var entrypoints = [
for (var argument in argResults!.rest)
for (var entry in Glob(argument).listSync())
for (var entry in Glob(argument).listFileSystemSync(fileSystem))
if (entry is File) entry.path
];
for (var entrypoint in entrypoints) {
Expand Down
3 changes: 2 additions & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: sass_migrator
version: 1.3.8
version: 1.3.9
description: A tool for running migrations on Sass files
author: Jennifer Thakar <[email protected]>
homepage: https://github.com/sass/migrator
Expand All @@ -11,6 +11,7 @@ dependencies:
args: ^2.1.0
charcode: ^1.2.0
collection: ^1.15.0
file: ^6.1.0
glob: ^2.0.1
js: ^0.6.3
meta: ^1.3.0
Expand Down

0 comments on commit ef02c63

Please sign in to comment.