Unverified Commit 1884920e authored by Zachary Anderson's avatar Zachary Anderson Committed by GitHub

[flutter_tool] Handle Windows line endings in packages_test.dart (#63806)

parent 579cab8a
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
// found in the LICENSE file. // found in the LICENSE file.
import 'dart:async'; import 'dart:async';
import 'dart:convert';
import 'package:args/command_runner.dart'; import 'package:args/command_runner.dart';
import 'package:flutter_tools/src/base/bot_detector.dart'; import 'package:flutter_tools/src/base/bot_detector.dart';
...@@ -37,10 +38,14 @@ void main() { ...@@ -37,10 +38,14 @@ void main() {
final String projectPath = await createProject(tempDir, arguments: arguments); final String projectPath = await createProject(tempDir, arguments: arguments);
final File pubspec = globals.fs.file(globals.fs.path.join(projectPath, 'pubspec.yaml')); final File pubspec = globals.fs.file(globals.fs.path.join(projectPath, 'pubspec.yaml'));
String content = await pubspec.readAsString(); String content = await pubspec.readAsString();
content = content.replaceFirst( final List<String> contentLines = LineSplitter.split(content).toList();
'\ndependencies:\n', final int depsIndex = contentLines.indexOf('dependencies:');
'\ndependencies:\n $plugin:\n', expect(depsIndex, isNot(-1));
); contentLines.replaceRange(depsIndex, depsIndex + 1, <String>[
'dependencies:',
' $plugin:',
]);
content = contentLines.join('\n');
await pubspec.writeAsString(content, flush: true); await pubspec.writeAsString(content, flush: true);
return projectPath; return projectPath;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment