pubspec_schema.dart 921 Bytes
Newer Older
Ian Hickson's avatar
Ian Hickson committed
1
// Copyright 2014 The Flutter Authors. All rights reserved.
2 3 4
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
import 'package:file/file.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/flutter_manifest.dart';

/// Writes a schemaData used for validating pubspec.yaml files when parsing
/// asset information.
void writeSchemaFile(FileSystem filesystem, String schemaData) {
  final String schemaPath = buildSchemaPath(filesystem);
  final File schemaFile = filesystem.file(schemaPath);

  final String schemaDir = buildSchemaDir(filesystem);

  filesystem.directory(schemaDir).createSync(recursive: true);
  schemaFile.writeAsStringSync(schemaData);
}

/// Writes an empty schemaData that will validate any pubspec.yaml file.
void writeEmptySchemaFile(FileSystem filesystem) {
  writeSchemaFile(filesystem, '{}');
}