Skip to content

Commit 70112b6

Browse files
authored
Cleanup (flutter#20)
* dartfmt * use new Travis CI Dart tasks * A couple of lint fixes * use recommended name for analysis_options
1 parent b6e30c8 commit 70112b6

15 files changed

+56
-54
lines changed

.travis.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
language: dart
22
sudo: false
33
dart:
4-
- stable
54
- dev
6-
script: ./tool/travis.sh
5+
- stable
6+
- 1.23.0
7+
- 1.22.1
8+
cache:
9+
directories:
10+
- $HOME/.pub-cache
11+
dart_task:
12+
- test: --platform vm
13+
- dartfmt
14+
- dartanalyzer

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
* The preferred top-level method is now `createStaticHandler`. `getHandler` is deprecated.
6969
* Set `content-type` header if the mime type of the requested file can be determined from the file extension.
7070
* Respond with `304-Not modified` against `IF-MODIFIED-SINCE` request header.
71-
* Better error when provided a non-existant `fileSystemPath`.
71+
* Better error when provided a non-existent `fileSystemPath`.
7272
* Added `example/example_server.dart`.
7373

7474
## 0.1.1+1

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
`shelf_static` is a `Handler` for the Dart `shelf` package.
22

33
[![Build Status](https://travis-ci.org/dart-lang/shelf_static.svg?branch=master)](https://travis-ci.org/dart-lang/shelf_static?branch=master)
4-
[![Coverage Status](https://coveralls.io/repos/dart-lang/shelf_static/badge.svg?branch=master&service=github)](https://coveralls.io/github/dart-lang/shelf_static?branch=master)
54

65
### Example
76
```dart
File renamed without changes.

example/example_server.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ ArgParser _getParser() => new ArgParser()
6060
abbr: 'f',
6161
defaultsTo: false,
6262
negatable: false,
63-
help: 'List the files in the source directory instead of servering the default document - "$_defaultDoc".');
63+
help: 'List the files in the source directory instead of serving the '
64+
'default document - "$_defaultDoc".');
6465

6566
const _defaultDoc = 'index.html';

lib/src/directory_listing.dart

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,12 @@ Response listDirectory(String fileSystemPath, String dirPath) {
7777
controller.add(encoding.encode(string));
7878
}
7979

80-
String heading = path.relative(dirPath, from: fileSystemPath);
81-
if (heading == '.') heading = '/';
82-
else heading = '/$heading/';
80+
var heading = path.relative(dirPath, from: fileSystemPath);
81+
if (heading == '.') {
82+
heading = '/';
83+
} else {
84+
heading = '/$heading/';
85+
}
8386

8487
add(_getHeader(sanitizer.convert(heading)));
8588
new Directory(dirPath).list().listen((FileSystemEntity entity) {

lib/src/static_handler.dart

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ Handler createStaticHandler(String fileSystemPath,
6464

6565
var entityType = FileSystemEntity.typeSync(fsPath, followLinks: true);
6666

67-
File file = null;
67+
File file;
6868

6969
if (entityType == FileSystemEntityType.FILE) {
7070
file = new File(fsPath);
@@ -115,14 +115,15 @@ Handler createStaticHandler(String fileSystemPath,
115115

116116
String contentType;
117117
if (useHeaderBytesForContentType) {
118-
var length =
119-
math.min(contentTypeResolver.magicNumbersMaxLength, file.lengthSync());
118+
var length = math.min(
119+
contentTypeResolver.magicNumbersMaxLength, file.lengthSync());
120120

121121
var byteSink = new ByteAccumulatorSink();
122122

123123
await file.openRead(0, length).listen(byteSink.add).asFuture();
124124

125-
contentType = contentTypeResolver.lookup(file.path, headerBytes: byteSink.bytes);
125+
contentType =
126+
contentTypeResolver.lookup(file.path, headerBytes: byteSink.bytes);
126127
} else {
127128
contentType = contentTypeResolver.lookup(file.path);
128129
}

test/alternative_root_test.dart

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,10 @@ void main() {
2020
});
2121

2222
d.file('root.txt', 'root txt').create();
23-
d
24-
.dir('files', [
23+
d.dir('files', [
2524
d.file('test.txt', 'test txt content'),
2625
d.file('with space.txt', 'with space content')
27-
])
28-
.create();
26+
]).create();
2927

3028
currentSchedule.onComplete.schedule(() {
3129
d.defaultRoot = null;

test/basic_file_test.dart

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
import 'dart:io';
65
import 'dart:convert';
6+
import 'dart:io';
7+
78
import 'package:http_parser/http_parser.dart';
89
import 'package:mime/mime.dart' as mime;
910
import 'package:path/path.dart' as p;
@@ -35,7 +36,8 @@ void main() {
3536
r"OJE7pB/VXmF3CdseucmjxaAruR41Pl9p/Gbyoq5B9FeL2OR7zJ+3aC/X8QdQCyIArPs"
3637
r"HkQAAAABJRU5ErkJggg==";
3738

38-
var webpBytesContent = r"UklGRiQAAABXRUJQVlA4IBgAAAAwAQCdASoBAAEAAQAcJaQAA3AA/v3AgAA=";
39+
var webpBytesContent =
40+
r"UklGRiQAAABXRUJQVlA4IBgAAAAwAQCdASoBAAEAAQAcJaQAA3AA/v3AgAA=";
3941

4042
d.dir('files', [
4143
d.file('test.txt', 'test txt content'),
@@ -226,8 +228,16 @@ void main() {
226228
test('header_bytes_test_webp should be image/webp', () {
227229
schedule(() {
228230
final mime.MimeTypeResolver resolver = new mime.MimeTypeResolver();
229-
resolver.addMagicNumber(<int>[0x52,0x49,0x46,0x46,0x00,0x00,0x00,0x00,0x57,0x45,0x42,0x50], "image/webp",
230-
mask: <int>[0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF]);
231+
resolver.addMagicNumber(
232+
<int>[
233+
0x52, 0x49, 0x46, 0x46, 0x00, 0x00, //
234+
0x00, 0x00, 0x57, 0x45, 0x42, 0x50
235+
],
236+
"image/webp",
237+
mask: <int>[
238+
0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, //
239+
0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF
240+
]);
231241
final dynamic handler = createStaticHandler(d.defaultRoot,
232242
useHeaderBytesForContentType: true, contentTypeResolver: resolver);
233243

@@ -237,6 +247,5 @@ void main() {
237247
});
238248
});
239249
});
240-
241250
});
242251
}

test/default_document_test.dart

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,10 @@ void main() {
2323

2424
d.file('index.html', '<html></html>').create();
2525
d.file('root.txt', 'root txt').create();
26-
d
27-
.dir('files', [
26+
d.dir('files', [
2827
d.file('index.html', '<html><body>files</body></html>'),
2928
d.file('with space.txt', 'with space content')
30-
])
31-
.create();
29+
]).create();
3230

3331
currentSchedule.onComplete.schedule(() {
3432
d.defaultRoot = null;

0 commit comments

Comments
 (0)