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
5a0edf9f
Commit
5a0edf9f
authored
Feb 16, 2016
by
Adam Barth
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1917 from abarth/pub_get
flutter run should run pub get automatically
parents
feceb758
cf811636
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
59 additions
and
34 deletions
+59
-34
create.dart
packages/flutter_tools/lib/src/commands/create.dart
+1
-34
run.dart
packages/flutter_tools/lib/src/commands/run.dart
+11
-0
pub.dart
packages/flutter_tools/lib/src/dart/pub.dart
+47
-0
No files found.
packages/flutter_tools/lib/src/commands/create.dart
View file @
5a0edf9f
...
...
@@ -12,7 +12,7 @@ import 'package:path/path.dart' as path;
import
'../android/android.dart'
as
android
;
import
'../artifacts.dart'
;
import
'../base/globals.dart'
;
import
'../
base/process
.dart'
;
import
'../
dart/pub
.dart'
;
import
'ios.dart'
;
class
CreateCommand
extends
Command
{
...
...
@@ -70,39 +70,6 @@ All done! To run your application:
printStatus
(
message
);
return
0
;
}
Future
<
int
>
pubGet
({
String
directory:
''
,
bool
skipIfAbsent:
false
})
async
{
File
pubSpecYaml
=
new
File
(
path
.
join
(
directory
,
'pubspec.yaml'
));
File
pubSpecLock
=
new
File
(
path
.
join
(
directory
,
'pubspec.lock'
));
File
dotPackages
=
new
File
(
path
.
join
(
directory
,
'.packages'
));
if
(!
pubSpecYaml
.
existsSync
())
{
if
(
skipIfAbsent
)
return
0
;
printError
(
'
$directory
: no pubspec.yaml found'
);
return
1
;
}
if
(!
pubSpecLock
.
existsSync
()
||
pubSpecYaml
.
lastModifiedSync
().
isAfter
(
pubSpecLock
.
lastModifiedSync
()))
{
printStatus
(
"Running 'pub get' in '
$directory
'..."
);
int
code
=
await
runCommandAndStreamOutput
(
<
String
>[
sdkBinaryName
(
'pub'
),
'--verbosity=warning'
,
'get'
],
workingDirectory:
directory
);
if
(
code
!=
0
)
return
code
;
}
if
((
pubSpecLock
.
existsSync
()
&&
pubSpecLock
.
lastModifiedSync
().
isAfter
(
pubSpecYaml
.
lastModifiedSync
()))
&&
(
dotPackages
.
existsSync
()
&&
dotPackages
.
lastModifiedSync
().
isAfter
(
pubSpecYaml
.
lastModifiedSync
())))
return
0
;
printError
(
'
$directory
: pubspec.yaml, pubspec.lock, and .packages are in an inconsistent state'
);
return
1
;
}
}
abstract
class
Template
{
...
...
packages/flutter_tools/lib/src/commands/run.dart
View file @
5a0edf9f
...
...
@@ -11,6 +11,7 @@ import '../application_package.dart';
import
'../base/common.dart'
;
import
'../base/globals.dart'
;
import
'../build_configuration.dart'
;
import
'../dart/pub.dart'
;
import
'../device.dart'
;
import
'../flx.dart'
;
import
'../runner/flutter_command.dart'
;
...
...
@@ -68,11 +69,21 @@ class RunCommand extends RunCommandBase {
defaultsTo:
false
,
negatable:
false
,
help:
'Start in a paused mode and wait for a debugger to connect.'
);
argParser
.
addFlag
(
'pub'
,
defaultsTo:
true
,
help:
'Whether to run "pub get" before running the app.'
);
argParser
.
addOption
(
'debug-port'
,
defaultsTo:
observatoryDefaultPort
.
toString
(),
help:
'Listen to the given port for a debug connection.'
);
}
@override
Future
<
int
>
run
()
async
{
if
(
argResults
[
'pub'
])
await
pubGet
();
return
await
super
.
run
();
}
@override
Future
<
int
>
runInProject
()
async
{
printTrace
(
'Downloading toolchain.'
);
...
...
packages/flutter_tools/lib/src/dart/pub.dart
0 → 100644
View file @
5a0edf9f
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'dart:async'
;
import
'dart:io'
;
import
'package:path/path.dart'
as
path
;
import
'../base/globals.dart'
;
import
'../base/process.dart'
;
Future
<
int
>
pubGet
({
String
directory
,
bool
skipIfAbsent:
false
})
async
{
if
(
directory
==
null
)
directory
=
Directory
.
current
.
path
;
File
pubSpecYaml
=
new
File
(
path
.
join
(
directory
,
'pubspec.yaml'
));
File
pubSpecLock
=
new
File
(
path
.
join
(
directory
,
'pubspec.lock'
));
File
dotPackages
=
new
File
(
path
.
join
(
directory
,
'.packages'
));
if
(!
pubSpecYaml
.
existsSync
())
{
if
(
skipIfAbsent
)
return
0
;
printError
(
'
$directory
: no pubspec.yaml found'
);
return
1
;
}
if
(!
pubSpecLock
.
existsSync
()
||
pubSpecYaml
.
lastModifiedSync
().
isAfter
(
pubSpecLock
.
lastModifiedSync
()))
{
printStatus
(
"Running 'pub get' in '
$directory
'..."
);
int
code
=
await
runCommandAndStreamOutput
(
<
String
>[
sdkBinaryName
(
'pub'
),
'--verbosity=warning'
,
'get'
],
workingDirectory:
directory
);
if
(
code
!=
0
)
return
code
;
}
if
((
pubSpecLock
.
existsSync
()
&&
pubSpecLock
.
lastModifiedSync
().
isAfter
(
pubSpecYaml
.
lastModifiedSync
()))
&&
(
dotPackages
.
existsSync
()
&&
dotPackages
.
lastModifiedSync
().
isAfter
(
pubSpecYaml
.
lastModifiedSync
())))
return
0
;
printError
(
'
$directory
: pubspec.yaml, pubspec.lock, and .packages are in an inconsistent state'
);
return
1
;
}
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