-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathworker.js
More file actions
69 lines (55 loc) · 1.87 KB
/
Copy pathworker.js
File metadata and controls
69 lines (55 loc) · 1.87 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
'use strict'
var Toolbelt = require('strider-deconst-common').Toolbelt
var build = require('./lib')
module.exports = {
init: function (config, job, jobContext, callback) {
callback(null, {
env: {},
path: [],
test: function (phaseContext, done) {
var toolbelt = new Toolbelt(config, job, jobContext, phaseContext)
if (toolbelt.isPullRequest) {
toolbelt.debug('Testing pull request %s.', toolbelt.pullRequestURL)
var dockerErr = toolbelt.connectToDocker()
if (hadError(dockerErr, done)) return
optionalConnection(toolbelt.connectToStagingPresenter())
optionalConnection(toolbelt.connectToStagingContentService(true))
optionalConnection(toolbelt.connectToGitHub())
build.preparePullRequest(toolbelt, function (err, results) {
hadError(err)
done(err, results ? results.didSomething : true)
})
} else {
done(null, true)
}
},
deploy: function (phaseContext, done) {
var toolbelt = new Toolbelt(config, job, jobContext, phaseContext)
var err = toolbelt.connectToDocker()
if (hadError(err, done)) return
var opts = {
contentServiceURL: config.contentServiceURL,
contentServiceAPIKey: config.contentServiceAPIKey
}
build.recursivelyPrepare(toolbelt, opts, function (err, results) {
hadError(err)
done(err, results.didSomething)
})
}
})
}
}
// Post-process any Errors from lower-level functions to trick Strider into using them to fail
// the build rather than error it out.
var hadError = function (err, done) {
if (err) {
err.type = 'exitCode'
err.code = 1
if (done) done(err)
return true
}
return false
}
var optionalConnection = function (toolbelt, err) {
if (err) toolbelt.error(err.message)
}