curist / grunt-bower

grunt task to copy bower installed packages to other folder(s)
MIT License
93 stars 27 forks source link

Feature : Expandable source file paths #29

Closed antwan closed 10 years ago

antwan commented 10 years ago

This PR adds support for grunt paths expansion (as in grunt-contrib-copy). With this feature, users are now able to specify expandable paths using grunt.file.expand-comprehensible format.

For example the config :

packageSpecific: {
    'jquery-ui': {
        files: [
            'ui/minified/jquery-ui.min.js',
            'themes/base/minified/**'
        ]
    }
},

can be used to deploy all files from the folder themes/base/minified, including subfolders and keeping the hierarchy.

It is also possible to flatten the dest hierarchy using the new setting keepExpandedHierarchy=false either from global or packageSpecific options.

Note this PR include the previous one (#27)

curist commented 10 years ago

Thanks for implementing this, will merge it as soon as possible. 2014/5/3 上午2:08 於 "Antoine" notifications@github.com 寫道:

This PR adds support for grunt paths expansion (as in grunt-contrib-copy). With this feature, users are now able to specify expandable paths using grunt.file.expand-comprehensiblehttp://gruntjs.com/api/grunt.file#grunt.file.expandformat.

For example the config :

packageSpecific: { 'jquery-ui': { files: [ 'ui/minified/jquery-ui.min.js', 'themes/base/minified/**' ] }},

can be used to deploy all files from the folder themes/base/minified, including subfolders and keeping the hierarchy.

It is also possible to flatten the dest hierarchy using the new setting keepExpandedHierarchy=false either from global or packageSpecific options.

Note this PR include the previous one (#27https://github.com/curist/grunt-bower/pull/27

)

You can merge this Pull Request by running

git pull https://github.com/Antwan86/grunt-bower feature/expand-paths

Or view, comment on, or merge it at:

https://github.com/curist/grunt-bower/pull/29 Commit Summary

  • Change : Does not copy main file unless specified when using packageSpecific/files option
  • Added support for path expansion, Added option : keepExpandedHierarchy

File Changes

  • M tasks/bower.jshttps://github.com/curist/grunt-bower/pull/29/files#diff-0(31)

Patch Links:

— Reply to this email directly or view it on GitHubhttps://github.com/curist/grunt-bower/pull/29 .

curist commented 10 years ago

I'm confused by the way you implementing keepExpandedHierarchy. Can you give some sample project to work with the new keepExpandedHierarchy option? I can't seem to get it to work.

The path expansion part is good, merged and published.

adambiggs commented 10 years ago

This simply does not work for me. Using the above example, the files in themes/base/minified are flattened - the subfolder structure is not preserved.

I also get lots of errors in the console:

Fail to copy bower_components/jquery-ui/themes/base/minified/subdirectory for jquery-ui!
antwan commented 10 years ago

Hi @curist Unfortunately I can't make it work too using your last changes. I think you still need the base dir calculation (cf 7721a71c4228c9db84833a17141c28dd4f53e771 line 224) to make it work or the hierarchy will be lost. You can remove the option keepExpandedHierarchy but you can't get rid of this part or the paths will be flattened. FYI the option actually disable the base dir calculation resulting to this effect.

@adambiggs same for me, try commit 7721a71c4228c9db84833a17141c28dd4f53e771 and tell us if it works.

curist commented 10 years ago

I am not why sure I thought it didn't work, just tried again your commit, and it works. Sorry about that. Will publish a new version soon.

antwan commented 10 years ago

Hey @curist, Thanks for the merge. Do you think it's possible to reimport the commit 0cbbbfb362d36dd63288f533ec8b554607b9c805 too, as it included a fix for filename destination (line 96).

With this, when you specify a single file to import using files option, it keeps the name instead of renaming to the default one (package name).

packageSpecific: {
    'jquery': {
        files: [
            'dist/jquery.min.js'
        ]
    },
}

Without the fix, this file is copied : -> public/scripts/vendor/jquery/jquery.js With the fix, this file is copied : -> public/scripts/vendor/jquery/jquery.min.js

I think it makes more sense. What are you thoughts about this ?

curist commented 10 years ago

I actually meant to cherry-pick 0cbbbfb362d36dd63288f533ec8b554607b9c805 too. Hang on, will update it soon.

adambiggs commented 10 years ago

Thanks @Antwan86 and @curist, this seems to be working now.