Skip to content

Commit

Permalink
linting
Browse files Browse the repository at this point in the history
  • Loading branch information
yoiang committed Jan 15, 2018
1 parent 350bb84 commit eb7e2fe
Showing 1 changed file with 23 additions and 23 deletions.
46 changes: 23 additions & 23 deletions dist/index.js.flow
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import Firebase from 'firebase-admin'
import fs from 'fs'
import mkdirp from 'mkdirp'

export default function(accountCredentials: string | Object, backupPath: string, prettyPrintJSON: boolean) {
// from: https://hackernoon.com/functional-javascript-resolving-promises-sequentially-7aac18c4431e
export default function (accountCredentials: string | Object, backupPath: string, prettyPrintJSON: boolean) {
// from: https://hackernoon.com/functional-javascript-resolving-promises-sequentially-7aac18c4431e
const promiseSerial = (funcs) => {
return funcs.reduce(
(promise, func) => {
Expand Down Expand Up @@ -43,13 +43,13 @@ export default function(accountCredentials: string | Object, backupPath: string,
}

return document.ref.getCollections()
.then((collections) => {
return promiseSerial(collections.map((collection) => {
return () => {
return backupCollection(collection, backupPath + '/' + collection.id, logPath + document.id + '/')
}
}))
})
.then((collections) => {
return promiseSerial(collections.map((collection) => {
return () => {
return backupCollection(collection, backupPath + '/' + collection.id, logPath + document.id + '/')
}
}))
})
}

const backupCollection = (collection: Object, backupPath: string, logPath: string) => {
Expand All @@ -61,26 +61,26 @@ export default function(accountCredentials: string | Object, backupPath: string,
}

return collection.get()
.then((documentSnapshots) => {
const backupFunctions = []
documentSnapshots.forEach((document) => {
backupFunctions.push(() => {
return backupDocument(document, backupPath + '/' + document.id, logPath + collection.id + '/')
})
.then((documentSnapshots) => {
const backupFunctions = []
documentSnapshots.forEach((document) => {
backupFunctions.push(() => {
return backupDocument(document, backupPath + '/' + document.id, logPath + collection.id + '/')
})
return promiseSerial(backupFunctions)
})
return promiseSerial(backupFunctions)
})
}

const backupRootCollections = (database: Object) => {
return database.getCollections()
.then((collections) => {
return promiseSerial(collections.map((collection) => {
return () => {
return backupCollection(collection, backupPath + '/' + collection.id, '/')
}
}))
})
.then((collections) => {
return promiseSerial(collections.map((collection) => {
return () => {
return backupCollection(collection, backupPath + '/' + collection.id, '/')
}
}))
})
}

let accountCredentialsContents: Object
Expand Down

0 comments on commit eb7e2fe

Please sign in to comment.