diff --git a/src/post-processor.js b/src/post-processor.js index bc95ba5..9b0be8a 100644 --- a/src/post-processor.js +++ b/src/post-processor.js @@ -1,20 +1,10 @@ -const findProcessorName = args => { - const ctx = args.find(ctx => Reflect.has(ctx, 'processor') && Reflect.has(ctx.processor, 'name')); - let name = ctx ? ctx.processor.name : undefined; +const detect = args => { + const {processor: {name, plugins}} = args.find(ctx => Reflect.has(ctx, 'processor') && Reflect.has(ctx.processor, 'name')); - // Detect postcss - if (name === undefined && args[0].type === 'root' && Reflect.has(args[1], 'processor')) { - name = 'postcss'; + return { + name: (name || 'postcss').toLowerCase(), + plugins } - - // Detect reshape - if (name === undefined && Reflect.has(args[1], 'ReshapeError')) { - name = 'reshape'; - } - - return name.toLowerCase(); }; -export default (...ctx) => ({ - name: findProcessorName(ctx) -}); +export default (...ctx) => detect(ctx);