Skip to content

Commit

Permalink
perf(*): update detect, add reshape
Browse files Browse the repository at this point in the history
  • Loading branch information
Scrum committed Feb 10, 2017
1 parent 1387421 commit 1ab4d4b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default (...options) => {
let warning = [];

return (ctx, res) => {
const processor = postProcessor(ctx);
const processor = postProcessor(ctx, res);
const config = postSequence(postConfig(...options)[processor.name].plugins, {processor: processor.name, namespace: true});
const plugins = Object.keys(config)
.map(plugin => loadPlugin(plugin, warning, processor)(config[plugin]))
Expand Down
14 changes: 13 additions & 1 deletion src/post-processor.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,19 @@ import Reflect from 'core-js/library/es6/reflect';

const findProcessorName = args => {
const ctx = args.find(ctx => Reflect.has(ctx, 'processor') && Reflect.has(ctx.processor, 'name'));
return ctx ? ctx.processor.name : 'postcss';
let name = ctx ? ctx.processor.name : undefined;

// detect postcss
if (name === undefined && args[0].type === 'root' && Reflect.has(args[1], 'processor')) {
name = 'postcss';
}

// detect reshape
if (name === undefined && Reflect.has(args[1], 'ReshapeError')) {
name = 'reshape';
}

return name;
};

export default (...ctx) => {
Expand Down

0 comments on commit 1ab4d4b

Please sign in to comment.