Skip to content

Commit

Permalink
bugfixes for use as package
Browse files Browse the repository at this point in the history
  • Loading branch information
wdiesveld committed May 8, 2020
1 parent 979155a commit 6041d05
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ $config = [
'label' => 'your-project-label'
],
'compiler' => [
'dialect' => 'mysql'
'dialect' => 'mysql',
'input' => './tinyqueries',
'output' => './sql'
]
Expand Down
Binary file modified bin/tqc.phar
Binary file not shown.
8 changes: 7 additions & 1 deletion src/TinyQueries/Compiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ private static function addFolderRecursivelyToZip(&$zip, $folder, $folderRelativ

public function compile(array $config, string $apiKey, bool $verbose = false)
{
self::standardizeConfig($config);

if (!function_exists('curl_init')) {
throw new \Exception('Cannot compile queries - curl extension for PHP is not installed');
}
Expand All @@ -133,7 +135,11 @@ public function compile(array $config, string $apiKey, bool $verbose = false)
throw new \Exception("Cannot open $zipFileName");
}

$zip->addFile($config['fileName']);
if (isset($config['fileName'])) {
$zip->addFile($config['fileName']);
} else {
$zip->addFromString('tinyqueries.json', json_encode($config));
}

self::addFolderRecursivelyToZip($zip, $config['compiler']['input']);

Expand Down

0 comments on commit 6041d05

Please sign in to comment.