Skip to content

Commit

Permalink
Create local puro path only when install
Browse files Browse the repository at this point in the history
  • Loading branch information
rehlma committed Jun 12, 2024
1 parent 9f24106 commit 41326d9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion lib/src/install_puro.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ Directory installPuroStandalone(String version, dcli.Progress? progress) {
final puroLinuxDownloadUrl = "https://puro.dev/builds/$version/linux-x64/puro";

int resultCode = -1;
final downloadPath = getPuroStandaloneBinPath();
final downloadPath = getPuroStandaloneBinPath(createIfNotExists: true);
if (Platform.isWindows) {
resultCode = installPuroStandaloneWindows(puroWindowsDownloadUrl, downloadPath, progress);
} else if (Platform.isMacOS) {
Expand Down
20 changes: 11 additions & 9 deletions lib/src/puro.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,22 @@ File? getPuroPath() {
path = which.path;
}
if (path == null) {
final result = dcli.find('puro', workingDirectory: getPuroStandaloneBinPath().path, recursive: false);
path = result.firstLine;
final standalonePath = getPuroStandaloneBinPath();
if (standalonePath.existsSync()) {
final result = dcli.find('puro', workingDirectory: standalonePath.path, recursive: false);
path = result.firstLine;
}
}
return path != null ? File(path) : null;
}

Directory getPuroStandaloneBinPath() {
final installDir = Directory("${SidekickContext.sidekickPackage.buildDir.absolute.path}/puro");

final puroPath = '${installDir.path}/bin/';
if (!dcli.exists(puroPath)) {
dcli.createDir(puroPath, recursive: true);
/// Returns the puro standalone bin path. It may not exist.
Directory getPuroStandaloneBinPath({bool createIfNotExists = false}) {
final path = Directory("${SidekickContext.sidekickPackage.buildDir.absolute.path}/puro/bin/");
if (createIfNotExists && !path.existsSync()) {
path.createSync(recursive: true);
}
return Directory(puroPath);
return path;
}

/// Thrown when puro is not found
Expand Down

0 comments on commit 41326d9

Please sign in to comment.