Skip to content

Commit

Permalink
Merge pull request #213 from todbachman-wf/rap-1618_skip_dot_pub_cont…
Browse files Browse the repository at this point in the history
…ents

RAP-1618 Skip files in .pub directories when formatting
  • Loading branch information
jayudey-wf authored Feb 9, 2017
2 parents 9bef141 + 48d8aa8 commit cd78dba
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/src/tasks/format/api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ FormatTask format(
if (!entity.path.endsWith('.dart')) continue;
// Skip dependency files.
if (entity.absolute.path.contains('/packages/')) continue;
// Skip contents of .pub directories.
if (entity.absolute.path.contains('/.pub/')) continue;

// Skip excluded files.
bool isExcluded = false;
Expand Down
16 changes: 16 additions & 0 deletions test/integration/format_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -98,5 +98,21 @@ void main() {
String contentsAfter = file.readAsStringSync();
expect(contentsBefore, equals(contentsAfter));
});

test('should skip files in "packages" when excludes specified', () async {
File file = new File('$projectWithExclusions/lib/packages/main.dart');
String contentsBefore = file.readAsStringSync();
expect(await formatProject(projectWithExclusions), isTrue);
String contentsAfter = file.readAsStringSync();
expect(contentsBefore, equals(contentsAfter));
});

test('should skip files in ".pub" when excludes specified', () async {
File file = new File('$projectWithExclusions/lib/.pub/main.dart');
String contentsBefore = file.readAsStringSync();
expect(await formatProject(projectWithExclusions), isTrue);
String contentsAfter = file.readAsStringSync();
expect(contentsBefore, equals(contentsAfter));
});
});
}
9 changes: 9 additions & 0 deletions test_fixtures/format/exclusions/lib/.pub/main.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
library main;

List longList = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten'];

void doStuff(
content
) {
print( content );
}
9 changes: 9 additions & 0 deletions test_fixtures/format/exclusions/lib/packages/main.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
library main;

List longList = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten'];

void doStuff(
content
) {
print( content );
}

0 comments on commit cd78dba

Please sign in to comment.