-
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathbuild-required.js
More file actions
43 lines (32 loc) · 862 Bytes
/
build-required.js
File metadata and controls
43 lines (32 loc) · 862 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
'use strict'
const strftime = require('strftime').timezone(0)
const after = require('after')
const listBuilds = require('./list-builds')
const latestCommit = require('./latest-commit')
const dateFormat = '%Y%m%d'
function timeString () {
return strftime(dateFormat)
}
function buildRequired (type, ref, force, config, callback) {
let builds
let commit
const done = after(2, (err) => {
if (err) {
return callback(err)
}
commit = commit.substr(0, 10)
if (!force && builds.some((b) => b.commit.substr(0, 10) === commit)) {
return callback()
}
return callback(null, { type, commit, date: timeString() })
})
listBuilds(type, config, (err, data) => {
builds = data
done(err)
})
latestCommit(type, ref, config, (err, data) => {
commit = data
done(err)
})
}
module.exports = buildRequired