be4df1a869
This aligns names with ResourceProvider.getFile/Folder. Change-Id: I30383ef1fa6f7cbe60b187338e25b8ca75806730 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/511120 Reviewed-by: Johnni Winther <johnniwinther@google.com> Reviewed-by: Jonas Jensen <jonasfj@google.com> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
36 lines
1.3 KiB
Dart
36 lines
1.3 KiB
Dart
// Copyright (c) 2016, 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 'package:analyzer/file_system/file_system.dart';
|
|
import 'package:yaml/yaml.dart';
|
|
|
|
/// The name of the embedder files being searched for.
|
|
const String _embedderFileName = '_embedder.yaml';
|
|
|
|
/// Given the lib directory of a 'sky_engine' package, locates an
|
|
/// `_embedder.yaml` file.
|
|
///
|
|
/// If the file can be found, and contains a top level [YamlMap], then
|
|
/// the [YamlMap] is returned. Otherwise, `null`` is returned.
|
|
YamlMap? locateEmbedderYamlFor(Folder libFolder) {
|
|
File file = libFolder.getFile(_embedderFileName);
|
|
try {
|
|
var embedderYaml = file.readAsStringSync();
|
|
try {
|
|
if (loadYaml(embedderYaml) case YamlMap yaml) {
|
|
return yaml;
|
|
}
|
|
} on Exception {
|
|
// TODO(srawlins): If we ever get a malformed `_embedder.yaml` file, we
|
|
// completely suppress the parse exception. We could instead wire up an
|
|
// ErrorListener for the call to `loadYaml` above, and/or catch different
|
|
// exceptions and write them to the instrumentation log.
|
|
}
|
|
return null;
|
|
} on FileSystemException {
|
|
// File can't be read.
|
|
return null;
|
|
}
|
|
}
|