@almyty/skills 1.0.4 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auth.js +13 -1
- package/package.json +1 -1
package/dist/auth.js
CHANGED
|
@@ -30,7 +30,19 @@ function loadCredentials() {
|
|
|
30
30
|
*/
|
|
31
31
|
export function resolveAuth() {
|
|
32
32
|
const envToken = process.env.ALMYTY_TOKEN;
|
|
33
|
-
|
|
33
|
+
// Read URL from: env > config file > default
|
|
34
|
+
let configUrl;
|
|
35
|
+
try {
|
|
36
|
+
const { readFileSync, existsSync } = require('fs');
|
|
37
|
+
const { join } = require('path');
|
|
38
|
+
const { homedir } = require('os');
|
|
39
|
+
const configPath = join(homedir(), '.almyty', 'config.json');
|
|
40
|
+
if (existsSync(configPath)) {
|
|
41
|
+
configUrl = JSON.parse(readFileSync(configPath, 'utf-8')).apiUrl;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
catch { }
|
|
45
|
+
const envUrl = process.env.ALMYTY_URL || configUrl || 'https://api.almyty.com';
|
|
34
46
|
if (envToken) {
|
|
35
47
|
return { url: envUrl, token: envToken };
|
|
36
48
|
}
|