blob: fcc1fe1e722351c7ffd4a0ca2e5d798d0eb47858 [file] [log] [blame]
// Copyright (c) 2022, 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:convert';
import 'dart:io';
import 'package:dart2js_info/binary_serialization.dart' as binary;
import 'package:dart2js_info/info.dart';
import 'package:dart2js_info/json_info_codec.dart';
Future<AllInfo> infoFromFile(String fileName) async {
var file = File(fileName);
if (fileName.endsWith('.json')) {
return AllInfoJsonCodec().decode(jsonDecode(await file.readAsString()));
} else {
return binary.decode(file.readAsBytesSync());
}
}