Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix firebase get method not returning its promise #349

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"github-build": "^1.2.0",
"glob": "^7.1.4",
"gzip-size": "^4.0.0",
"minimatch": "^3.0.4",
"prettycli": "^1.4.3"
},
"lint-staged": {
Expand Down
2 changes: 1 addition & 1 deletion src/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ config.map(file => {
const maxSize = bytes(file.maxSize) || Infinity
const compression = file.compression || 'gzip'
const size = compressedSize(fs.readFileSync(path, 'utf8'), compression)
files.push({ maxSize, path, size, compression })
files.push({ maxSize, path, size, compression, globPath: file.path })
})
}
})
Expand Down
3 changes: 2 additions & 1 deletion src/reporter.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const bytes = require('bytes')
const { error, warn, info } = require('prettycli')
const { event, repo, branch, commit_message, sha } = require('ci-env')
const minimatch = require('minimatch')
const build = require('./build')
const api = require('./api')
const debug = require('./debug')
Expand Down Expand Up @@ -74,7 +75,7 @@ const getGlobalMessage = ({
const analyse = ({ files, masterValues }) => {
return files.map(file => {
let fail = false
file.master = masterValues[file.path]
file.master = masterValues[Object.keys(masterValues).find((key) => minimatch(key, file.globPath))]
const { path, size, master, maxSize, compression = 'gzip' } = file

let compressionText = '(no compression)'
Expand Down
9 changes: 5 additions & 4 deletions store/firebase.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,18 @@ const set = (repo, values, sha, token) => {
const get = (repo, token) => {
authenticate(token)
const ref = `${token}/${repo}`
database
return database
.ref(ref)
.limitToLast(1)
.once('value')
.then(snapshot => {
const object = snapshot.val()
if (!object) return []
const values = Object.values(object)[0]
return values
return Object.values(object)[0]
})
.finally(() => {
logout()
})
logout()
}

module.exports = { set, get }
3 changes: 3 additions & 0 deletions store/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,8 @@
},
"devDependencies": {
"pug-lint": "^2.5.0"
},
"engines": {
"node": "12.x"
}
}