Skip to content
Snippets Groups Projects
Commit e92ad553 authored by nweiz@google.com's avatar nweiz@google.com Committed by Natalie Weizenbaum
Browse files

Produce useful error messages for empty pubspecs.

BUG=20103
R=blois@google.com

Review URL: https://codereview.chromium.org//417023002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge@38565 260f80e4-7a28-3924-810f-c04153c831b5
parent d37242d5
No related branches found
No related tags found
No related merge requests found
......@@ -273,11 +273,9 @@ class Pubspec {
/// [Version.none].
factory Pubspec.parse(String contents, SourceRegistry sources,
{String expectedName, Uri location}) {
if (contents.trim() == '') return new Pubspec.empty();
var pubspecNode = loadYamlNode(contents, sourceUrl: location);
if (pubspecNode is YamlScalar && pubspecNode.value == null) {
pubspecNode = new YamlMap();
pubspecNode = new YamlMap(sourceUrl: location);
} else if (pubspecNode is! YamlMap) {
throw new PubspecException(
'The pubspec must be a YAML mapping.', pubspecNode.span);
......
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS d.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 d.file.
import 'package:path/path.dart' as p;
import '../../../lib/src/exit_codes.dart' as exit_codes;
import '../../descriptor.dart' as d;
import '../../test_pub.dart';
main() {
initConfig();
// Regression test for issue 20103.
integration('path dependency to an empty pubspec', () {
d.dir('foo', [
d.libDir('foo'),
d.file('pubspec.yaml', '')
]).create();
d.dir(appPath, [
d.appPubspec({
"foo": {"path": "../foo"}
})
]).create();
pubGet(exitCode: exit_codes.DATA, error:
'Error on line 1, column 1 of ${p.join('..', 'foo', 'pubspec.yaml')}: '
'Missing the required "name" field.');
});
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment