@diplodoc/cli 4.13.7 → 4.13.9-alpha-1

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.
@@ -1,42 +0,0 @@
1
- import {readFile} from 'fs/promises';
2
- import {env} from 'process';
3
- import {homedir} from 'os';
4
- import {join} from 'path';
5
-
6
- import {logger} from '../../utils';
7
-
8
- const YANDEX_OAUTH_TOKEN_FILENAME = '.ya_oauth_token';
9
-
10
- async function getYandexOAuthToken() {
11
- const {YANDEX_OAUTH_TOKEN} = env;
12
-
13
- return YANDEX_OAUTH_TOKEN ?? getYandexOAuthTokenFromHomeDir();
14
- }
15
-
16
- async function getYandexOAuthTokenFromHomeDir() {
17
- const error = 'failed reading yandex oauth token';
18
-
19
- const path = join(homedir(), YANDEX_OAUTH_TOKEN_FILENAME);
20
-
21
- let token;
22
-
23
- try {
24
- token = await readFile(path, {encoding: 'utf8'});
25
-
26
- token = token.trim();
27
-
28
- if (!token?.length) {
29
- throw new Error(error);
30
- }
31
- } catch (err) {
32
- logger.error(error);
33
-
34
- throw err;
35
- }
36
-
37
- return token;
38
- }
39
-
40
- export {getYandexOAuthToken};
41
-
42
- export default {getYandexOAuthToken};