aboutsummaryrefslogtreecommitdiff
path: root/src/constants.ts
diff options
context:
space:
mode:
authordependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>2021-09-06 21:06:22 +0000
committerGitHub <noreply@github.com>2021-09-06 21:06:22 +0000
commit487f208565894f332ca58c13e1b208c3beb9c8c6 (patch)
treeb3209e94cc63658b5430bc1949b80140cc27efe4 /src/constants.ts
parent4f03cb71b30978b277ff292dbddeba182117a7cb (diff)
downloadskyblock-api-487f208565894f332ca58c13e1b208c3beb9c8c6.tar.gz
skyblock-api-487f208565894f332ca58c13e1b208c3beb9c8c6.tar.bz2
skyblock-api-487f208565894f332ca58c13e1b208c3beb9c8c6.zip
Bump node-fetch from 2.6.1 to 3.0.0 (#116)
* Bump node-fetch from 2.6.1 to 3.0.0 Bumps [node-fetch](https://github.com/node-fetch/node-fetch) from 2.6.1 to 3.0.0. - [Release notes](https://github.com/node-fetch/node-fetch/releases) - [Changelog](https://github.com/node-fetch/node-fetch/blob/main/docs/CHANGELOG.md) - [Commits](https://github.com/node-fetch/node-fetch/compare/v2.6.1...v3.0.0) --- updated-dependencies: - dependency-name: node-fetch dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> * fix issues with node fetch 3.0 * change module to esnext instead of commonjs * fix imports and tests * fix package-lock.json Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: mat <github@matdoes.dev> Co-authored-by: mat <27899617+mat-1@users.noreply.github.com>
Diffstat (limited to 'src/constants.ts')
-rw-r--r--src/constants.ts19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/constants.ts b/src/constants.ts
index dcb9acf..13fc21d 100644
--- a/src/constants.ts
+++ b/src/constants.ts
@@ -3,14 +3,14 @@
*/
// we have to do this so we can mock the function from the tests properly
-import * as constants from './constants'
+import * as constants from './constants.js'
import * as nodeFetch from 'node-fetch'
import NodeCache from 'node-cache'
+import { debug } from './index.js'
import Queue from 'queue-promise'
import fetch from 'node-fetch'
import { Agent } from 'https'
-import { debug } from '.'
const httpsAgent = new Agent({
keepAlive: true
@@ -87,7 +87,7 @@ function fetchFile(path: string): Promise<GithubFile> {
'Accept': 'application/vnd.github.v3+json',
},
)
- const data = await r.json()
+ const data = await r.json() as any
const file = {
path: data.path,
@@ -118,7 +118,7 @@ async function editFile(file: GithubFile, message: string, newContent: string):
branch: 'main'
}
)
- const data = await r.json()
+ const data = await r.json() as any
fileCache.set(file.path, {
path: data.content.path,
content: newContent,
@@ -126,7 +126,7 @@ async function editFile(file: GithubFile, message: string, newContent: string):
})
}
-export async function fetchJSONConstant(filename: string): Promise<any> {
+export let fetchJSONConstant = async function fetchJSONConstant(filename: string): Promise<any> {
const file = await fetchFile(filename)
try {
return JSON.parse(file.content)
@@ -137,7 +137,7 @@ export async function fetchJSONConstant(filename: string): Promise<any> {
}
/** Add stats to skyblock-constants. This has caching so it's fine to call many times */
-export async function addJSONConstants(filename: string, addingValues: string[], unit: string='stat'): Promise<void> {
+export let addJSONConstants = async function addJSONConstants(filename: string, addingValues: string[], unit: string='stat'): Promise<void> {
if (addingValues.length === 0) return // no stats provided, just return
let file: GithubFile = await fetchFile(filename)
@@ -269,4 +269,9 @@ export async function setConstantValues(newValues: constantValues) {
try {
await editFile(file, commitMessage, JSON.stringify(updatedStats, null, 2))
} catch {}
-} \ No newline at end of file
+}
+
+
+// this is necessary for mocking in the tests because es6
+export function mockAddJSONConstants($value) { addJSONConstants = $value }
+export function mockFetchJSONConstant($value) { fetchJSONConstant = $value }