-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
40 lines (30 loc) · 947 Bytes
/
index.js
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
const _ = require('lodash');
const gitClone = _.curry(require('./gitClone'), 2);
const gitFile = _.curry(require('./gitFile'), 2);
const gitFileAs = _.curry(require('./gitFileAs'), 2);
const gitPlugin = {
type: 'git',
scriptHashes: [],
getFile(ctx) {
return gitFile(ctx);
},
getFileAs(ctx) {
return gitFileAs(ctx);
},
getSource(app, target) {
return gitClone(
{ url: app.source.url
, referenceValue: app.source.referenceValue
, target: target
}
);
},
postAction(source, rootDir, repoHash, deployConfig, tools) {
if (!source.postClone) return tools.executeScript(null);
const script = `cd ${rootDir}; ${_.template(source.postClone)({ rootDir: rootDir })}`;
if (_.includes(gitPlugin.scriptHashes, script.toString())) return (next) => next();
gitPlugin.scriptHashes.push(script.toString());
return tools.executeScript(script);
}
};
module.exports = gitPlugin;