Skip to content

Commit

Permalink
add isExecutable to CachedArtifact
Browse files Browse the repository at this point in the history
  • Loading branch information
bryanoltman committed Jan 2, 2024
1 parent bb268bd commit 183384a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
25 changes: 18 additions & 7 deletions packages/shorebird_cli/lib/src/cache.dart
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,14 @@ abstract class CachedArtifact {

String get storageUrl;

String get executable;
String get fileName;

bool get isExecutable;

bool get required => true;

Future<void> extractArtifact(http.ByteStream stream, String outputPath) {
final file = File(p.join(outputPath, executable))
final file = File(p.join(outputPath, fileName))
..createSync(recursive: true);
return stream.pipe(file.openWrite());
}
Expand Down Expand Up @@ -180,10 +182,10 @@ allowed to access $storageUrl.''',

await extractArtifact(response.stream, location.path);

if (!platform.isWindows) {
if (!platform.isWindows && isExecutable) {
final result = await process.start(
'chmod',
['+x', p.join(location.path, executable)],
['+x', p.join(location.path, fileName)],
);
await result.exitCode;
}
Expand All @@ -199,7 +201,10 @@ class AotToolsArtifact extends CachedArtifact {
// Not technically an executable, but this is where the file should end up and
// is how it will be consumed.
@override
String get executable => 'aot-tools.dill';
String get fileName => 'aot-tools.dill';

@override
bool get isExecutable => false;

/// The aot-tools are only available for revisions that support mixed-mode.
@override
Expand All @@ -225,7 +230,10 @@ class PatchArtifact extends CachedArtifact {
String get name => 'patch';

@override
String get executable => 'patch';
String get fileName => 'patch';

@override
bool get isExecutable => true;

@override
Future<void> extractArtifact(
Expand Down Expand Up @@ -260,7 +268,10 @@ class BundleToolArtifact extends CachedArtifact {
String get name => 'bundletool.jar';

@override
String get executable => 'bundletool.jar';
String get fileName => 'bundletool.jar';

@override
bool get isExecutable => false;

@override
String get storageUrl {
Expand Down
5 changes: 4 additions & 1 deletion packages/shorebird_cli/test/src/cache_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ class TestCachedArtifact extends CachedArtifact {
String get name => 'test';

@override
String get executable => 'test';
String get fileName => 'test';

@override
bool get isExecutable => true;

@override
String get storageUrl => 'test-url';
Expand Down

0 comments on commit 183384a

Please sign in to comment.