Skip to content

Commit

Permalink
Added support for global ENV settings
Browse files Browse the repository at this point in the history
  • Loading branch information
wdiesveld committed May 7, 2020
1 parent 7fec52e commit 7ebc629
Show file tree
Hide file tree
Showing 5 changed files with 130 additions and 32 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ sudo chmod +x /usr/local/bin/tqc

It is assumed you have a folder for your project. It can be an empty folder or a folder which contains other code as well.
- Make sure you have an API key for the TinyQueries™ Compiler. You can get one here: https://tinyqueries.com/signup
- Create a file `.env` in the root of your project folder if you don't have one yet and add your API key:
- Either add `TINYQUERIES_API_KEY` to your ENV variabeles OR create a file `.env` in the root of your project folder if you don't have one yet and add your API key:
```
TINYQUERIES_API_KEY=<yourkey>
```
Expand All @@ -46,4 +46,3 @@ Once you have setup your project you just have to execute
tqc
```
from your project folder each time you want to compile your source files

9 changes: 6 additions & 3 deletions app/tqc.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,17 @@
function getApiKey() : string
{
$dotenv = new Dotenv();
$dotenv->load('.env');
$key = getenv('TINYQUERIES_API_KEY');
try {
$dotenv->overload('.env');
} catch (\Exception $e) {
}
$key = $_ENV['TINYQUERIES_API_KEY'] ?? getenv('TINYQUERIES_API_KEY');

if (!$key) {
throw new \Exception('No API key found');
}

return $key;
return trim($key);
}

function readConfig() : array
Expand Down
Binary file modified bin/tqc.phar
Binary file not shown.
9 changes: 2 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,7 @@
"ext-zip": "*",
"ext-json": "*",
"ext-curl": "*",
"symfony/dotenv": "^3.3",
"symfony/yaml": "^3.3"
},
"config": {
"platform": {
"php": "7"
}
"symfony/dotenv": "^5.0",
"symfony/yaml": "^5.0"
}
}
141 changes: 121 additions & 20 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7ebc629

Please sign in to comment.