Skip to content

Commit

Permalink
fixed breakage of /makeplugin caused by da1df37
Browse files Browse the repository at this point in the history
  • Loading branch information
dktapps committed Oct 26, 2020
1 parent a520c9b commit 5fa5d2a
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/DevTools/DevTools.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,12 +216,6 @@ private function makePluginCommand(CommandSender $sender, array $args) : bool{

$pharPath = $this->getDataFolder() . $description->getName() . "_v" . $description->getVersion() . ".phar";

if($description->getName() === "DevTools"){
$stub = sprintf(DEVTOOLS_REQUIRE_FILE_STUB, "src/DevTools/ConsoleScript.php");
}else{
$stub = sprintf(DEVTOOLS_PLUGIN_STUB, $description->getName(), $description->getVersion(), $this->getDescription()->getVersion(), date("r"));
}

$reflection = new \ReflectionClass(PluginBase::class);
$file = $reflection->getProperty("file");
$file->setAccessible(true);
Expand All @@ -236,6 +230,16 @@ private function makePluginCommand(CommandSender $sender, array $args) : bool{
$metadata = generatePluginMetadataFromYml($filePath . "plugin.yml");
assert($metadata !== null);

if($description->getName() === "DevTools"){
$stub = sprintf(DEVTOOLS_REQUIRE_FILE_STUB, "src/DevTools/ConsoleScript.php");
}else{
$stubMetadata = [];
foreach($metadata as $key => $value){
$stubMetadata[] = addslashes(ucfirst($key) . ": " . (is_array($value) ? implode(", ", $value) : $value));
}
$stub = sprintf(DEVTOOLS_PLUGIN_STUB, $description->getName(), $description->getVersion(), $this->getDescription()->getVersion(), date("r"), implode("\n", $stubMetadata));
}

$this->buildPhar($sender, $pharPath, $filePath, [], $metadata, $stub, \Phar::SHA1);

$sender->sendMessage("Phar plugin " . $description->getName() . " v" . $description->getVersion() . " has been created on " . $pharPath);
Expand Down

0 comments on commit 5fa5d2a

Please sign in to comment.