Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
9e212017
Commit
9e212017
authored
Nov 17, 2015
by
Adam Barth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a --version option to flutter
This option just prints the current git revision. Fixes #40
parent
6f0464c0
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
5 deletions
+20
-5
flutter_command_runner.dart
...lutter_tools/lib/src/commands/flutter_command_runner.dart
+11
-0
process.dart
packages/flutter_tools/lib/src/process.dart
+9
-5
No files found.
packages/flutter_tools/lib/src/commands/flutter_command_runner.dart
View file @
9e212017
...
...
@@ -33,6 +33,9 @@ class FlutterCommandRunner extends CommandRunner {
negatable:
false
,
help:
'Very noisy logging, including the output of all '
'shell commands executed.'
);
argParser
.
addFlag
(
'version'
,
negatable:
false
,
help:
'Reports the version of this tool.'
);
String
packagesHelp
;
if
(
ArtifactStore
.
isPackageRootValid
)
packagesHelp
=
'
\n
(defaults to "
${ArtifactStore.packageRoot}
")'
;
...
...
@@ -138,6 +141,14 @@ class FlutterCommandRunner extends CommandRunner {
if
(
globalResults
.
wasParsed
(
'package-root'
))
ArtifactStore
.
packageRoot
=
globalResults
[
'package-root'
];
if
(
globalResults
[
'version'
])
{
String
revision
=
runSync
([
'git'
,
'rev-parse'
,
'HEAD'
],
workingDirectory:
ArtifactStore
.
flutterRoot
).
trim
();
print
(
'flutter version
$revision
'
);
return
new
Future
<
int
>.
value
(
0
);
}
return
super
.
runCommand
(
globalResults
);
}
...
...
packages/flutter_tools/lib/src/process.dart
View file @
9e212017
...
...
@@ -64,11 +64,12 @@ Future<Process> runDetached(List<String> cmd) {
/// Run cmd and return stdout.
/// Throws an error if cmd exits with a non-zero value.
String
runCheckedSync
(
List
<
String
>
cmd
)
=>
_runWithLoggingSync
(
cmd
,
checked:
true
);
String
runCheckedSync
(
List
<
String
>
cmd
,
{
String
workingDirectory
}
)
=>
_runWithLoggingSync
(
cmd
,
workingDirectory:
workingDirectory
,
checked:
true
);
/// Run cmd and return stdout.
String
runSync
(
List
<
String
>
cmd
)
=>
_runWithLoggingSync
(
cmd
);
String
runSync
(
List
<
String
>
cmd
,
{
String
workingDirectory
})
=>
_runWithLoggingSync
(
cmd
,
workingDirectory:
workingDirectory
);
/// Return the platform specific name for the given Dart SDK binary. So, `pub`
/// ==> `pub.bat`.
...
...
@@ -76,10 +77,13 @@ String sdkBinaryName(String name) {
return
Platform
.
isWindows
?
'
$name
.bat'
:
name
;
}
String
_runWithLoggingSync
(
List
<
String
>
cmd
,
{
bool
checked:
false
})
{
String
_runWithLoggingSync
(
List
<
String
>
cmd
,
{
bool
checked:
false
,
String
workingDirectory
})
{
_logging
.
info
(
cmd
.
join
(
' '
));
ProcessResult
results
=
Process
.
runSync
(
cmd
[
0
],
cmd
.
getRange
(
1
,
cmd
.
length
).
toList
());
Process
.
runSync
(
cmd
[
0
],
cmd
.
getRange
(
1
,
cmd
.
length
).
toList
()
,
workingDirectory:
workingDirectory
);
if
(
results
.
exitCode
!=
0
)
{
String
errorDescription
=
'Error code
${results.exitCode}
'
'returned when attempting to run command:
${cmd.join(' ')}
'
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment