()
| 26 | fs.mkdir(dirname(options.tokens_store_path), { recursive: true }); |
| 27 | |
| 28 | async function loadCustomTokens() { |
| 29 | try { |
| 30 | const stats = await fs.stat(options.tokens_store_path); |
| 31 | |
| 32 | if (tokensCache && stats.mtime.getTime() <= cacheLastModified) { |
| 33 | return tokensCache; |
| 34 | } |
| 35 | |
| 36 | tokensCache = JSON.parse( |
| 37 | await fs.readFile(options.tokens_store_path, "utf-8"), |
| 38 | ); |
| 39 | cacheLastModified = Date.now(); |
| 40 | |
| 41 | return tokensCache; |
| 42 | } catch { |
| 43 | tokensCache = {}; |
| 44 | cacheLastModified = Date.now(); |
| 45 | |
| 46 | return tokensCache; |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | async function saveCustomTokens(tokens) { |
| 51 | await fs.writeFile(options.tokens_store_path, JSON.stringify(tokens)); |
no outgoing calls
no test coverage detected