Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Verbose Options #105

Open
blond opened this issue Feb 11, 2015 · 7 comments
Open

Verbose Options #105

blond opened this issue Feb 11, 2015 · 7 comments

Comments

@blond
Copy link
Member

blond commented Feb 11, 2015

Options in all techs can be divided into three types: targets, sources and options.

Now, all options are set as a flat list. Because of this, not possible to understand what type of each option.

var techs = require('enb-bem-techs'),
    css = require('css-stylus-with-autoprefixer');

nodeConfig.addTechs([
    [techs.levels, {
        levels: ['blocks'],
        target: '?.levels'
    }],
    [techs.bemjsonToBemdecl, {
        source: '?.bemjson.js',
        target: '?.bemdecl.js'
    }],
    [techs.deps, {
        levelsTarget: '?.levels',
        bemdeclFile: '?.bemdecl.js'
        target: '?.deps.js'
    }],
    [techs.files, {
        levelsTarget: '?.levels',
        depsFile: '?.deps.js',
        filesTarget: '?.files',
        dirsTarget: '?.dirs'
    }],
    [css, {
        target: '?.css',
        filesTarget: '?.files',
        browsers: ['ie 7', 'ie 8']
    }]
]);

We can explicitly indicate which of the options are sources, which targets, and which options.

 var techs = require('enb-bem-techs');

nodeConfig.addTechs([
    [techs.levels, {
        sources: ['blocks'],
        target: '?.levels'
    }],
    [techs.bemjsonToBemdecl, {
        target: '?.bemdecl.js'
        source: '?.bemjson.js'
    }],
    [techs.deps, {
        target: '?.deps.js',
        sources: {
            levels: '?.levels',
            decl: '?.bemdecl.js'
        }
    }],
    [techs.files, {
        targets: {
            files: '?.files',
            dirs: '?.dirs'
        },        
        sources: {
            levels: '?.levels',
            decl: '?.deps.js',
        }
    }],
    [css, {
        target: '?.css',
        sources: {
            files: '?.files'
        },
        options: {
            browsers: ['ie 7', 'ie 8']
        }
    }]
]);
@qfox
Copy link
Contributor

qfox commented Feb 11, 2015

So you propose source/sources and target/targets as a standard for enb-techs? 👍 for that.

@tadatuta
Copy link
Member

cc @arikon

@qfox
Copy link
Contributor

qfox commented Feb 11, 2015

Options looks like overkill, btw. But I'm not against it.

@arikon
Copy link
Member

arikon commented Feb 12, 2015

@andrewblond Why not just use the generic prefixes consistently in all the techs?

  • targetDirs, targetFiles, targetBemjson
  • sourceDeps, sourceLevels, sourceFiles, sourceBemjson
  • (no prefix for options) browsers and so on

@blond
Copy link
Member Author

blond commented Feb 12, 2015

Why not just use the generic prefixes consistently in all the techs?

It seems that it less obvious and less unification between techs.

Options looks like overkill, btw. But I'm not against it.

Yes, it seems that without options will be better

@arikon
Copy link
Member

arikon commented Feb 13, 2015

@andrewblond I don't like the distinction between target and targets, source and sources.

What if some of sources are optional? Than I have to write single nested option:

{
  sources: {
    sourceBemjson: '...'
  }
}

For me the generic prefix (convention) is more obvious than grouped options.

@blond
Copy link
Member Author

blond commented Feb 13, 2015

For me the generic prefix (convention) is more obvious than grouped options.

If not group options then lost information that has more source options:

{
  sourceBemjson: '...'
}

if group then added not too many characters:

{
  sources: { bemjson: '...' }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants