Skip to content

Commit dec2d99

Browse files
remove dynamic require for formatter, dont allow use for pkg option
1 parent 8b193ff commit dec2d99

File tree

2 files changed

+6
-20
lines changed

2 files changed

+6
-20
lines changed

lib/output/formatters/index.js

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,20 @@
11
const _ = require('lodash');
2-
const recursive = require('recursive-readdir');
3-
const path = require('path');
42
const { Formatter } = require('../index');
53

6-
const formatters = {};
74
const EMPTY_FORMATTER = new Formatter();
85

6+
// can`t do it explicity, pkg dont allow dynamic require
7+
const formatters = {
8+
// eslint-disable-next-line
9+
Workflow: require('./Workflow.formatter.js')
10+
};
911

1012
class FormatterRegistry {
1113
static get(formatterName) {
1214
return formatters[formatterName] || EMPTY_FORMATTER;
1315
}
14-
15-
static set(name, formatter) {
16-
formatters[name] = formatter;
17-
}
1816
}
1917

20-
recursive(path.resolve(__dirname), (err, files) => {
21-
_.forEach(files, (file) => {
22-
const ending = '.formatter.js';
23-
if (file.endsWith(ending)) {
24-
// eslint-disable-next-line
25-
const formatter = require(file);
26-
const entityName = path.parse(file).base.replace(ending, '');
27-
FormatterRegistry.set(entityName, formatter);
28-
}
29-
});
30-
});
31-
3218
module.exports = {
3319
FormatterRegistry,
3420
};

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "codefresh",
3-
"version": "0.8.100",
3+
"version": "0.8.101",
44
"description": "Codefresh command line utility",
55
"main": "index.js",
66
"preferGlobal": true,

0 commit comments

Comments
 (0)