OLD | NEW |
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 import 'dart:async'; | 5 import 'dart:async'; |
6 // We need to use the 'io' prefix here, otherwise io.exitCode will shadow | 6 // We need to use the 'io' prefix here, otherwise io.exitCode will shadow |
7 // CommandOutput.exitCode in subclasses of CommandOutput. | 7 // CommandOutput.exitCode in subclasses of CommandOutput. |
8 import 'dart:io' as io; | 8 import 'dart:io' as io; |
9 | 9 |
10 import 'command_output.dart'; | 10 import 'command_output.dart'; |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 [Map<String, String> environment, String workingDirectory]) { | 96 [Map<String, String> environment, String workingDirectory]) { |
97 return new ProcessCommand._( | 97 return new ProcessCommand._( |
98 displayName, executable, arguments, environment, workingDirectory); | 98 displayName, executable, arguments, environment, workingDirectory); |
99 } | 99 } |
100 | 100 |
101 static Command copy(String sourceDirectory, String destinationDirectory) { | 101 static Command copy(String sourceDirectory, String destinationDirectory) { |
102 return new CleanDirectoryCopyCommand._( | 102 return new CleanDirectoryCopyCommand._( |
103 sourceDirectory, destinationDirectory); | 103 sourceDirectory, destinationDirectory); |
104 } | 104 } |
105 | 105 |
106 static Command pub(String pubCommand, String pubExecutable, | |
107 String pubspecYamlDirectory, String pubCacheDirectory, | |
108 {List<String> arguments: const <String>[]}) { | |
109 return new PubCommand._(pubCommand, pubExecutable, pubspecYamlDirectory, | |
110 pubCacheDirectory, arguments); | |
111 } | |
112 | |
113 static Command makeSymlink(String link, String target) { | 106 static Command makeSymlink(String link, String target) { |
114 return new MakeSymlinkCommand._(link, target); | 107 return new MakeSymlinkCommand._(link, target); |
115 } | 108 } |
116 | 109 |
117 /// A descriptive name for this command. | 110 /// A descriptive name for this command. |
118 final String displayName; | 111 final String displayName; |
119 | 112 |
120 /// Number of times this command *can* be retried. | 113 /// Number of times this command *can* be retried. |
121 int get maxNumRetries => 2; | 114 int get maxNumRetries => 2; |
122 | 115 |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
472 'to an attached device. Uses (and requires) adb.'; | 465 'to an attached device. Uses (and requires) adb.'; |
473 } | 466 } |
474 | 467 |
475 class JSCommandlineCommand extends ProcessCommand { | 468 class JSCommandlineCommand extends ProcessCommand { |
476 JSCommandlineCommand._( | 469 JSCommandlineCommand._( |
477 String displayName, String executable, List<String> arguments, | 470 String displayName, String executable, List<String> arguments, |
478 [Map<String, String> environmentOverrides = null]) | 471 [Map<String, String> environmentOverrides = null]) |
479 : super._(displayName, executable, arguments, environmentOverrides); | 472 : super._(displayName, executable, arguments, environmentOverrides); |
480 } | 473 } |
481 | 474 |
482 class PubCommand extends ProcessCommand { | |
483 final String command; | |
484 | |
485 PubCommand._(String pubCommand, String pubExecutable, | |
486 String pubspecYamlDirectory, String pubCacheDirectory, List<String> args) | |
487 : command = pubCommand, | |
488 super._( | |
489 'pub_$pubCommand', | |
490 new io.File(pubExecutable).absolute.path, | |
491 [pubCommand]..addAll(args), | |
492 {'PUB_CACHE': pubCacheDirectory}, | |
493 pubspecYamlDirectory); | |
494 | |
495 void _buildHashCode(HashCodeBuilder builder) { | |
496 super._buildHashCode(builder); | |
497 builder.addJson(command); | |
498 } | |
499 | |
500 bool _equal(PubCommand other) => | |
501 super._equal(other) && command == other.command; | |
502 } | |
503 | |
504 /// [ScriptCommand]s are executed by dart code. | 475 /// [ScriptCommand]s are executed by dart code. |
505 abstract class ScriptCommand extends Command { | 476 abstract class ScriptCommand extends Command { |
506 ScriptCommand._(String displayName) : super._(displayName); | 477 ScriptCommand._(String displayName) : super._(displayName); |
507 | 478 |
508 Future<ScriptCommandOutput> run(); | 479 Future<ScriptCommandOutput> run(); |
509 } | 480 } |
510 | 481 |
511 class CleanDirectoryCopyCommand extends ScriptCommand { | 482 class CleanDirectoryCopyCommand extends ScriptCommand { |
512 final String _sourceDirectory; | 483 final String _sourceDirectory; |
513 final String _destinationDirectory; | 484 final String _destinationDirectory; |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
585 | 556 |
586 void _buildHashCode(HashCodeBuilder builder) { | 557 void _buildHashCode(HashCodeBuilder builder) { |
587 super._buildHashCode(builder); | 558 super._buildHashCode(builder); |
588 builder.addJson(_link); | 559 builder.addJson(_link); |
589 builder.addJson(_target); | 560 builder.addJson(_target); |
590 } | 561 } |
591 | 562 |
592 bool _equal(MakeSymlinkCommand other) => | 563 bool _equal(MakeSymlinkCommand other) => |
593 super._equal(other) && _link == other._link && _target == other._target; | 564 super._equal(other) && _link == other._link && _target == other._target; |
594 } | 565 } |
OLD | NEW |