blob: 85de479d4c8d97d991d6f7202125049d5c7472be [file] [log] [blame]
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'dart:async';
import 'dart:convert';
import 'package:path/path.dart' as path;
import '../entrypoint.dart';
import '../io.dart';
import '../validator.dart';
/// Validates that a package's README exists and is valid utf-8.
class ReadmeValidator extends Validator {
ReadmeValidator(Entrypoint entrypoint) : super(entrypoint);
Future validate() {
return Future.sync(() {
var readme = entrypoint.root.readmePath;
if (readme == null) {
.add('Please add a file that describes your package.');
if (path.basename(readme) != '') {
warnings.add('Please consider renaming $readme to ``. '
var bytes = readBinaryFile(readme);
try {
// utf8.decode doesn't allow invalid UTF-8.
} on FormatException catch (_) {
warnings.add('$readme contains invalid UTF-8.\n'
'This will cause it to be displayed incorrectly on '
'the Pub site (');