Refactor [github] initialization (#1861)
This creates a new convenience class which consolidates all the Github initialization. It supports dependency injection and facilitates refactoring the persistence along the lines of #1205. Also ref #1848
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
'use strict'
|
||||
|
||||
const path = require('path')
|
||||
const crypto = require('crypto')
|
||||
const log = require('./log')
|
||||
const queryString = require('query-string')
|
||||
@@ -14,12 +13,7 @@ const mapKeys = require('lodash.mapkeys')
|
||||
// with a JsonSave object.
|
||||
let githubUserTokens = { data: [] }
|
||||
|
||||
function scheduleAutosaving(config) {
|
||||
const { dir: persistenceDir } = config
|
||||
const githubUserTokensFile = path.resolve(
|
||||
persistenceDir,
|
||||
'github-user-tokens.json'
|
||||
)
|
||||
function scheduleAutosaving(githubUserTokensFile) {
|
||||
autosave(githubUserTokensFile, { data: [] })
|
||||
.then(save => {
|
||||
githubUserTokens = save
|
||||
|
||||
Reference in New Issue
Block a user