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

type parameter of layout function is __untyped__ #121

Open
agdev opened this issue Jul 8, 2014 · 3 comments
Open

type parameter of layout function is __untyped__ #121

agdev opened this issue Jul 8, 2014 · 3 comments
Labels

Comments

@agdev
Copy link

agdev commented Jul 8, 2014

Hi,

When I run grunt bower w/ following config I see that type'd value is "untyped"
Why is that?
bower: {
install: {
options: {
targetDir: './components',
install: true,
layout: function (type, component) {
grunt.log.writeln('type="' + type + '"');
grunt.log.writeln('component="' + component + '"');
var renamedType = type;
if (type == 'js') renamedType = 'scripts';
else if (type == 'css') renamedType = 'styles';

                    return path.join(component, renamedType);
                },
                bowerOptions: {forceLatest:true}
            }
        }
    }

Thank you.

@wpoch
Copy link

wpoch commented Sep 12, 2014

Did you get any workaround?, Is happening to me too. I want to integrate bower with sailsJs

@agdev
Copy link
Author

agdev commented Sep 15, 2014

No, I did not, was planning to write my own grunt plugin but did not get to it.

@mrchief
Copy link

mrchief commented Mar 18, 2015

A workaround is to inspect the 3rd argument passed and determine type based on file extension:

layout: function (type, component, source) {
    /* workaround for https://github.com/yatskevich/grunt-bower-task/issues/121 */
    if (type === '__untyped__') {
        type = source.substring(source.lastIndexOf('.') + 1);
    }

    var renamedType = type;

    if (type === 'js') renamedType = './Scripts';
    else if (type === 'css') renamedType = './Content';

    return path.join(component, renamedType);
}

Note: You can also use type = path.extname(source).replace('.', '') instead of type = source.substring(source.lastIndexOf('.') + 1);

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

No branches or pull requests

4 participants