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

minimatch (via ./lib/utils/findFileInfo.js) not working properly #20

Open
joaocc opened this issue Sep 20, 2015 · 1 comment
Open

minimatch (via ./lib/utils/findFileInfo.js) not working properly #20

joaocc opened this issue Sep 20, 2015 · 1 comment
Labels

Comments

@joaocc
Copy link

joaocc commented Sep 20, 2015

I have been trying to get this to work with our project, but with no luck.

.tmp/serve/index.html

     <script src="../bower_components/angular/angular.js"></script>

cdnizer options

var cndizerOpts =
  {
    allowRev: false,
    allowMin: false,
    files: [
      'google:angular'
    ]
  };

folder structure

(root)
    packages.json
    bower.json
    .bowerrc
    gulpfile.js
    gulp
        cdnizer.js
    node_modules/
    bower_components/
    src/
        index.html    (not-injected)        
    .tmp/
        serve/
            index.html    (injected)

bower.json

{
  "dependencies": {
    "angular": "~1.4.5",

I added some console.log entries to try and troubleshoot the problem (./utils/findFileInfo()).
It seems that the parsing is done correctly but minimatch says they are not matching:

in lib/util.js:findFileInfo, minimatch is called with what seem to be the right parameters, but returns null/false.

    url ===>>  "../bower_components/angular/angular.js"
    fileInfo.file ===>> "**/angular.js"

I also tried adding {dot: true} to the call to minimatch, but it still fails.

Any hints?
Thx

@OverZealous
Copy link
Owner

Not sure about fixing the specific issue, it looks like minimatch won't match ** against ../ unless it's explicitly included in the matcher.

The only solution I can think is to override the generated pattern by using:

files: [
    {
        // or you can be explicit and use `../bower_componentes/angular/angular.js`
        file: '../**/angular.js',
        cdn: 'google:angular'
    }
]

I can't find any practical way to fix it in a generic fashion within the code. I tried, but I couldn't make minimatch optionally match a relative parent (or, actually, any relative parent).

That really blows since relative paths aren't that uncommon. I'd basically have to make a special case for relative paths, and make extra matches. I suppose I could add an extra option for prefixing generated CDN paths, but it's pretty easy to override.

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

2 participants