Skip to content
Snippets Groups Projects
Commit bc776a2e authored by Natalie Weizenbaum's avatar Natalie Weizenbaum
Browse files

Write binstubs using the system encoding.

Closes #1304

R=rnystrom@google.com

Review URL: https://codereview.chromium.org//1248483003 .
parent 8abe1976
No related branches found
No related tags found
No related merge requests found
......@@ -5,6 +5,7 @@
library pub.global_packages;
import 'dart:async';
import 'dart:convert';
import 'dart:io';
import 'package:path/path.dart' as p;
......@@ -694,7 +695,9 @@ pub global run ${package.name}:$script "\$@"
""";
}
writeTextFile(binStubPath, bash);
// Write this as the system encoding since the system is going to execute
// it and it might contain non-ASCII caharacters in the pathnames.
writeTextFile(binStubPath, bash, encoding: const SystemEncoding());
// Make it executable.
var result = Process.runSync('chmod', ['+x', binStubPath]);
......
......@@ -165,14 +165,16 @@ List<int> readBinaryFile(String file) {
///
/// If [dontLogContents] is true, the contents of the file will never be logged.
String writeTextFile(String file, String contents,
{bool dontLogContents: false}) {
{bool dontLogContents: false, Encoding encoding}) {
if (encoding == null) encoding = UTF8;
// Sanity check: don't spew a huge file.
log.io("Writing ${contents.length} characters to text file $file.");
if (!dontLogContents && contents.length < 1024 * 1024) {
log.fine("Contents:\n$contents");
}
new File(file).writeAsStringSync(contents);
new File(file).writeAsStringSync(contents, encoding: encoding);
return 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