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
71aaa5db
Commit
71aaa5db
authored
Mar 13, 2017
by
Devon Carew
Committed by
GitHub
Mar 13, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add --offline to flutter packages get (#8707)
parent
f5a6c432
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
6 deletions
+30
-6
packages.dart
packages/flutter_tools/lib/src/commands/packages.dart
+12
-2
pub.dart
packages/flutter_tools/lib/src/dart/pub.dart
+5
-2
packages_test.dart
packages/flutter_tools/test/packages_test.dart
+13
-2
No files found.
packages/flutter_tools/lib/src/commands/packages.dart
View file @
71aaa5db
...
...
@@ -40,7 +40,12 @@ class PackagesGetCommand extends FlutterCommand {
final
bool
upgrade
;
PackagesGetCommand
(
this
.
name
,
this
.
upgrade
);
PackagesGetCommand
(
this
.
name
,
this
.
upgrade
)
{
argParser
.
addFlag
(
'offline'
,
negatable:
false
,
help:
'Use cached packages instead of accessing the network.'
);
}
// TODO: implement description
@override
...
...
@@ -68,6 +73,11 @@ class PackagesGetCommand extends FlutterCommand {
// TODO: If the user is using a local build, we should use the packages from their build instead of the cache.
await
pubGet
(
directory:
target
,
upgrade:
upgrade
,
checkLastModified:
false
);
await
pubGet
(
directory:
target
,
upgrade:
upgrade
,
offline:
argResults
[
'offline'
],
checkLastModified:
false
);
}
}
packages/flutter_tools/lib/src/dart/pub.dart
View file @
71aaa5db
...
...
@@ -29,6 +29,7 @@ Future<Null> pubGet({
String
directory
,
bool
skipIfAbsent:
false
,
bool
upgrade:
false
,
bool
offline:
false
,
bool
checkLastModified:
true
})
async
{
if
(
directory
==
null
)
...
...
@@ -47,8 +48,10 @@ Future<Null> pubGet({
final
String
command
=
upgrade
?
'upgrade'
:
'get'
;
final
Status
status
=
logger
.
startProgress
(
"Running 'flutter packages
$command
' in
${fs.path.basename(directory)}
..."
,
expectSlowOperation:
true
);
final
int
code
=
await
runCommandAndStreamOutput
(
<
String
>[
sdkBinaryName
(
'pub'
),
'--verbosity=warning'
,
command
,
'--no-packages-dir'
,
'--no-precompile'
],
final
List
<
String
>
args
=
<
String
>[
sdkBinaryName
(
'pub'
),
'--verbosity=warning'
,
command
,
'--no-packages-dir'
,
'--no-precompile'
];
if
(
offline
)
args
.
add
(
'--offline'
);
final
int
code
=
await
runCommandAndStreamOutput
(
args
,
workingDirectory:
directory
,
mapFunction:
_filterOverrideWarnings
,
environment:
<
String
,
String
>{
'FLUTTER_ROOT'
:
Cache
.
flutterRoot
}
...
...
packages/flutter_tools/test/packages_test.dart
View file @
71aaa5db
...
...
@@ -37,13 +37,18 @@ void main() {
await
runner
.
run
(<
String
>[
'create'
,
'--no-pub'
,
temp
.
path
]);
}
Future
<
Null
>
runCommand
(
String
verb
)
async
{
Future
<
Null
>
runCommand
(
String
verb
,
{
List
<
String
>
args
}
)
async
{
await
createProject
();
final
PackagesCommand
command
=
new
PackagesCommand
();
final
CommandRunner
<
Null
>
runner
=
createTestCommandRunner
(
command
);
await
runner
.
run
(<
String
>[
'packages'
,
verb
,
temp
.
path
]);
final
List
<
String
>
commandArgs
=
<
String
>[
'packages'
,
verb
];
if
(
args
!=
null
)
commandArgs
.
addAll
(
args
);
commandArgs
.
add
(
temp
.
path
);
await
runner
.
run
(
commandArgs
);
}
void
expectExists
(
String
relPath
)
{
...
...
@@ -57,6 +62,12 @@ void main() {
expectExists
(
'.packages'
);
});
testUsingContext
(
'get --offline'
,
()
async
{
await
runCommand
(
'get'
,
args:
<
String
>[
'--offline'
]);
expectExists
(
'lib/main.dart'
);
expectExists
(
'.packages'
);
});
testUsingContext
(
'upgrade'
,
()
async
{
await
runCommand
(
'upgrade'
);
expectExists
(
'lib/main.dart'
);
...
...
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