Closed fmal closed 6 years ago
Sounds like a good idea, I'm going to work on PR so we can try it out first.
Guessing how sequence
might look:
export default (...plugins: StartPlugin[]) =>
plugin('sequence', (props) =>
plugins.reduce(
async (prev, next) => {
const nextRunner = await next
const prevResult = await prev
return nextRunner({
...props,
...prevResult,
})
},
Promise.resolve(props)
)
)
You can track its progress in #38 – I really enjoyed the idea, it makes a lot of sense now.
@deepsweet looking great, i think it will make start runner more powerful. The same concept is implemented in Cerebral's actions (https://cerebraljs.com/docs/api/index.html#action-props) where action's output extends the payload for later actions in the sequence.
Going to publish as soon as it's possible :) Thanks again for the idea. Could you try it from master?
📦 plugin@0.2.0
Also every single plugin got updated.
@deepsweet thanks a lot, great job with that - just how i imagined it! Upgraded to 0.2.0
and love the flexibility it offers 👍
@deepsweet wonder what's your opinion on letting the user pass some extra input to the plugins?
Currently we're limited to
files
as input, but I have a case where i would like to measure some file sizes as first step and pass those sizes to another plugin further in the sequence. The sequence looks something like this[measureFileSizesBeforeBuild, cleanDist, copyAssets, build, printFileSizesAfterBuild]
, whereprintFileSizesAfterBuild
needssizes
frommeasureFileSizesBeforeBuild
to output difference. I thought it would be easiest to just return additional propresolve({ files, sizes })
and pass that trough the chain.To make it work i guess a tiny change would be required in https://github.com/deepsweet/start/blob/d8a323ac62e551d738b837be59e8ab0d94f95440/packages/plugin/src/index.ts#L29
{ reporter, files, ...additionalProps }
and then spreadingadditionalProps
in payload topluginFn()