FreeAllMedia / stimpak

An easy-to-use system for defining, discovering, and re-using code, text, and workflow patterns
http://stimpak.io
MIT License
8 stars 1 forks source link

Add .context feature #24

Closed dcrockwell closed 8 years ago

dcrockwell commented 8 years ago

Currently, there are a lot of .binds to make this pattern work:

export default class StimpakProject {
    constructor(stimpak) {
        stimpak
            .logo(`Project Generator v${packageJson.version}`)
            .then(this.promptProjectBasicInformation.bind(this));
    }

    promptProjectBasicInformation(stimpak, done) {
        stimpak
            .use(StimpakProjectBasicInformation)
            .then(this.promptVersionControl.bind(this));

        done();
    }

    promptVersionControl(stimpak, done) {
        stimpak
            .use(StimpakVersionControl)
            .then(this.promptNpm.bind(this));
        done();
    }

    promptNpm(stimpak, done) {
        stimpak
            .use(StimpakNpm)
            .then(this.promptGithub.bind(this));
        done();
    }

    promptGithub(stimpak, done) {
        stimpak
            .use(StimpakGithub)
            .then(this.promptTranspiling.bind(this));
        done();
    }

    promptTranspiling(stimpak, done) {
        stimpak
            .use(StimpakTranspiling);
        done();
    }
}

We could add a .context(newContextObject) method to set the context for all internal steps.

stimpak.context(someObject);

stimpak.then(function (stimpak, done) {
    // this === someObject
});
dcrockwell commented 8 years ago

Closed by https://github.com/FreeAllMedia/stimpak/pull/25