-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
39 lines (29 loc) · 883 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
const _ = require('lodash');
const fsClone = _.curry(require('./fsClone'), 2);
const fsFile = _.curry(require('./fsFile'), 2);
const fsFileAs = _.curry(require('./fsFileAs'), 2);
const fsPlugin = {
type: 'fs',
scriptHashes: [],
getFile(ctx) {
return fsFile(ctx);
},
getFileAs(ctx) {
return fsFileAs(ctx);
},
getSource(app, target) {
return fsClone(
{ url: app.source.url
, 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(fsPlugin.scriptHashes, script.toString())) return (next) => next();
fsPlugin.scriptHashes.push(script.toString());
return tools.executeScript(script);
}
};
module.exports = fsPlugin;