Skip to content

Commit

Permalink
Fix broken installation commands when the folder has whitespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
bastianallgeier committed Feb 6, 2024
1 parent 679a616 commit 31c0241
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion commands/download.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
'command' => static function (CLI $cli): void {
$client = new Client();
$progress = $cli->progress()->total(100);
$file = $cli->arg('file');

try {
$response = $client->get($cli->arg('url'), [
Expand All @@ -35,7 +36,7 @@
},
]);

file_put_contents($cli->arg('file'), (string)$response->getBody());
file_put_contents($file, (string)$response->getBody());
} catch (Throwable $e) {
throw new Exception('The file could not be downloaded. (Status: ' . $e->getResponse()->getStatusCode() . ')');
}
Expand Down
6 changes: 3 additions & 3 deletions commands/unzip.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
}

// extract the zip file
exec('unzip ' . $file . ' -d ' . $to);
exec('unzip ' . escapeshellarg($file) . ' -d ' . escapeshellarg($to));

$to = realpath($to);

Expand All @@ -40,7 +40,7 @@
throw new Exception('The archive directory could not be found');
}

exec('mv ' . $to . '/*/{.[!.],}* ' . $to . '/');
exec('rm -rf ' . $archive);
exec('mv ' . escapeshellarg($to) . '/*/{.[!.],}* ' . escapeshellarg($to) . '/');
exec('rm -rf ' . escapeshellarg($archive));
}
];

0 comments on commit 31c0241

Please sign in to comment.