-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
41 lines (35 loc) · 1.15 KB
/
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
41
'use strict';
const path = require('path');
const cp = require('child_process');
const Promise = require('bluebird');
const errorsParser = require('./errors-parser');
const LINTER_PATH = './migration/lib/index.js';
const LINTER_CWD = path.dirname(require.resolve('bem-xjst'));
module.exports = {
configure: () => ({
techs: {
'bemhtml.js': true
},
lint: true,
from: 0,
to: 8
}),
forEachTech: (tech, entity, config) => {
const conf = config.getConfig();
const args = ['--input', tech.path, '--from', conf.from, '--to', conf.to];
conf.lint && args.push('--lint');
return new Promise((resolve) => {
cp.execFile(LINTER_PATH, args, {cwd: LINTER_CWD}, (error, stdout, stderr) => {
errorsParser.parse(stderr).forEach((err) => {
entity.addError({
msg: 'bem-xjst error',
value: err.value,
tech: tech.name,
location: err.location
});
});
resolve();
});
});
}
};