feat(shorebird_cli): add previews directory to cache (#835)
This commit is contained in:
@@ -60,6 +60,14 @@ class Cache {
|
||||
);
|
||||
}
|
||||
|
||||
/// Get a named directory from with the cache's preview directory;
|
||||
/// for example, `foo` would return `bin/cache/previews/foo`.
|
||||
Directory getPreviewDirectory(String name) {
|
||||
return Directory(
|
||||
p.join(shorebirdPreviewsDirectory.path, p.withoutExtension(name)),
|
||||
);
|
||||
}
|
||||
|
||||
/// The Shorebird cache directory.
|
||||
static Directory get shorebirdCacheDirectory {
|
||||
return Directory(
|
||||
@@ -67,6 +75,13 @@ class Cache {
|
||||
);
|
||||
}
|
||||
|
||||
/// The Shorebird cached previews directory.
|
||||
static Directory get shorebirdPreviewsDirectory {
|
||||
return Directory(
|
||||
p.join(shorebirdCacheDirectory.path, 'previews'),
|
||||
);
|
||||
}
|
||||
|
||||
/// The Shorebird cached artifacts directory.
|
||||
static Directory get shorebirdArtifactsDirectory {
|
||||
return Directory(
|
||||
|
||||
@@ -63,7 +63,7 @@ class CodePushClientWrapper {
|
||||
Future<List<AppMetadata>> getApps() async {
|
||||
final fetchAppsProgress = logger.progress('Fetching apps');
|
||||
try {
|
||||
final apps = (await codePushClient.getApps()).toList();
|
||||
final apps = await codePushClient.getApps();
|
||||
fetchAppsProgress.complete();
|
||||
return apps;
|
||||
} catch (error) {
|
||||
|
||||
@@ -84,6 +84,40 @@ void main() {
|
||||
expect(Cache.new, returnsNormally);
|
||||
});
|
||||
|
||||
group('getArtifactDirectory', () {
|
||||
test('returns correct directory', () {
|
||||
final directory = cache.getArtifactDirectory('test');
|
||||
expect(
|
||||
directory.path.endsWith(
|
||||
p.join(
|
||||
'bin',
|
||||
'cache',
|
||||
'artifacts',
|
||||
'test',
|
||||
),
|
||||
),
|
||||
isTrue,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
group('getPreviewDirectory', () {
|
||||
test('returns correct directory', () {
|
||||
final directory = cache.getPreviewDirectory('test');
|
||||
expect(
|
||||
directory.path.endsWith(
|
||||
p.join(
|
||||
'bin',
|
||||
'cache',
|
||||
'previews',
|
||||
'test',
|
||||
),
|
||||
),
|
||||
isTrue,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
group('CachedArtifact', () {
|
||||
late CachedArtifact artifact;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user