Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(393)

Side by Side Diff: lib/src/global_packages.dart

Issue 1248483003: Write binstubs using the system encoding. (Closed) Base URL: git@github.com:dart-lang/pub.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | lib/src/io.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library pub.global_packages; 5 library pub.global_packages;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:convert';
8 import 'dart:io'; 9 import 'dart:io';
9 10
10 import 'package:path/path.dart' as p; 11 import 'package:path/path.dart' as p;
11 import 'package:barback/barback.dart'; 12 import 'package:barback/barback.dart';
12 import 'package:pub_semver/pub_semver.dart'; 13 import 'package:pub_semver/pub_semver.dart';
13 14
14 import 'barback/asset_environment.dart'; 15 import 'barback/asset_environment.dart';
15 import 'entrypoint.dart'; 16 import 'entrypoint.dart';
16 import 'exceptions.dart'; 17 import 'exceptions.dart';
17 import 'executable.dart' as exe; 18 import 'executable.dart' as exe;
(...skipping 669 matching lines...) Expand 10 before | Expand all | Expand 10 after
687 # If it is, we need to delete it and run "pub global" manually. 688 # If it is, we need to delete it and run "pub global" manually.
688 exit_code=\$? 689 exit_code=\$?
689 if [ \$exit_code != 253 ]; then 690 if [ \$exit_code != 253 ]; then
690 exit \$exit_code 691 exit \$exit_code
691 fi 692 fi
692 693
693 pub global run ${package.name}:$script "\$@" 694 pub global run ${package.name}:$script "\$@"
694 """; 695 """;
695 } 696 }
696 697
697 writeTextFile(binStubPath, bash); 698 // Write this as the system encoding since the system is going to execute
699 // it and it might contain non-ASCII caharacters in the pathnames.
700 writeTextFile(binStubPath, bash, encoding: const SystemEncoding());
698 701
699 // Make it executable. 702 // Make it executable.
700 var result = Process.runSync('chmod', ['+x', binStubPath]); 703 var result = Process.runSync('chmod', ['+x', binStubPath]);
701 if (result.exitCode != 0) { 704 if (result.exitCode != 0) {
702 // Couldn't make it executable so don't leave it laying around. 705 // Couldn't make it executable so don't leave it laying around.
703 try { 706 try {
704 deleteEntry(binStubPath); 707 deleteEntry(binStubPath);
705 } on IOException catch (err) { 708 } on IOException catch (err) {
706 // Do nothing. We're going to fail below anyway. 709 // Do nothing. We're going to fail below anyway.
707 log.fine("Could not delete binstub:\n$err"); 710 log.fine("Could not delete binstub:\n$err");
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
775 } 778 }
776 779
777 /// Returns the value of the property named [name] in the bin stub script 780 /// Returns the value of the property named [name] in the bin stub script
778 /// [source]. 781 /// [source].
779 String _binStubProperty(String source, String name) { 782 String _binStubProperty(String source, String name) {
780 var pattern = new RegExp(quoteRegExp(name) + r": ([a-zA-Z0-9_-]+)"); 783 var pattern = new RegExp(quoteRegExp(name) + r": ([a-zA-Z0-9_-]+)");
781 var match = pattern.firstMatch(source); 784 var match = pattern.firstMatch(source);
782 return match == null ? null : match[1]; 785 return match == null ? null : match[1];
783 } 786 }
784 } 787 }
OLDNEW
« no previous file with comments | « no previous file | lib/src/io.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698