Skip to content

Commit 1bec014

Browse files
committed
feature(@putout/engine-processor) getProcessorRunners: sync -> async
1 parent 396d88f commit 1bec014

3 files changed

Lines changed: 10 additions & 8 deletions

File tree

packages/engine-processor/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const {
1717
runProcessors,
1818
} = require('@putout/engine-processor');
1919

20-
const processorRunners = getProcessorRunners(processors);
20+
const processorRunners = await getProcessorRunners(processors);
2121

2222
runProcessors({
2323
name,

packages/engine-processor/lib/processor.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22

3-
const {loadProcessors} = require('@putout/engine-loader');
3+
const {loadProcessorsAsync} = require('@putout/engine-loader');
44
const picomatch = require('picomatch');
55

66
const defaultProcessors = [
@@ -29,7 +29,7 @@ module.exports.runProcessors = async ({name, fix, processFile, options, rawSourc
2929
processors = defaultProcessors,
3030
} = options;
3131

32-
processorRunners = processorRunners || getProcessorRunners(processors);
32+
processorRunners = processorRunners || await getProcessorRunners(processors);
3333

3434
let processedSource = '';
3535
let processedPlaces = [];
@@ -146,10 +146,12 @@ async function getFiles({name, fix, rawSource, processorRunners}) {
146146
}
147147

148148
module.exports.getProcessorRunners = getProcessorRunners;
149-
function getProcessorRunners(processors) {
150-
return loadProcessors({
149+
async function getProcessorRunners(processors) {
150+
const readyProcessors = await loadProcessorsAsync({
151151
processors,
152-
}).map(addGlobs);
152+
});
153+
154+
return readyProcessors.map(addGlobs);
153155
}
154156

155157
function addGlobs(processor) {

packages/engine-processor/test/processor.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,12 +222,12 @@ test('putout: engine-processor: markdown: no fix: return processed places', asyn
222222
});
223223

224224
// remark-lint cannot generate the same result as it was before parse,
225-
// it cannot distinguish "fix" and "report" ieither.
225+
// it cannot distinguish "fix" and "report" either.
226226
// So at first run with "--fix" on markdown file it will change it to simplified format.
227227
// even if nothing found 🤦🤷
228228
//
229229
// In this case we can benefit from:
230-
// - simplifiyng format of remark rules (which are splited on fix/report with help of options(!));
230+
// - simplifying format of remark rules (which are split on fix/report with help of options(!));
231231
// - splitting one big rule on a couple small rules;
232232
//
233233
// Otherwise it will mutate the tree and report all found errors, so only one big rule with

0 commit comments

Comments
 (0)