Skip to content

Commit

Permalink
Fix add package with offline flag (#4395)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcoedomingos authored Sep 27, 2024
1 parent 3a92e03 commit 9adca58
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/src/command/add.dart
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ For example:

@override
String get docUrl => 'https://dart.dev/tools/pub/cmd/pub-add';
@override
bool get isOffline => argResults.flag('offline');

AddCommand() {
argParser.addFlag(
Expand Down
10 changes: 10 additions & 0 deletions test/add/common/add_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1148,4 +1148,14 @@ dependency_overrides:

await pubAdd(args: ['foo'], output: contains('+ foo 1.0.0'));
});

test('`--offline` works', () async {
final server = await servePackages();
server.serve('foo', '1.0.0');
await runPub(args: ['cache', 'add', 'foo', '--version', '1.0.0']);

await d.appDir().create();
server.serve('foo', '2.0.0');
await pubAdd(args: ['foo', '--offline']);
});
}

0 comments on commit 9adca58

Please sign in to comment.