cdnjs / cdnjs-importer

Easier way to add your libraries in cdnjs.
Other
36 stars 13 forks source link

Importer duplicates folders and files #34

Open petrgazarov opened 7 years ago

petrgazarov commented 7 years ago

When the source contains folders, importer would copy folders, but then also copy the files inside of those folders and duplicate them on the top level of the resulting copy.

For example with this: https://github.com/jnicol/trackpad-scroll-emulator, here is the result of importing with cdnjs-importer:

      ▾ css/
          trackpad-scroll-emulator.css
      ▾ demo/
        ▾ css/
            demo-fullscreen.css
            demo.css
        ▾ js/lib/
            jquery-1.7.1.min.js*
          fullscreen-horiz.html
          fullscreen.html
          index.html
      ▾ js/lib/
          jquery-1.7.1.min.js*
      ▾ lib/
          jquery-1.7.1.min.js*
        bower.json
        demo-fullscreen.css
        demo.css
        fullscreen-horiz.html
        fullscreen.html
        Gruntfile.js
        index.html
        jquery-1.7.1.min.js*
        jquery.trackpad-scroll-emulator.js
        jquery.trackpad-scroll-emulator.min.js
        LICENSE
        package.json
        README.md
        trackpad-scroll-emulator.css

You can see that the files below the folders are the same files that are in the folders. The source does not contain duplicates.

I investigated briefly and it seems to come from Getting the library files step, where the files array ends up with both folders and files inside those folders.

So that in Copying the library files step, I put a logger inside map and this is what I got:

info  Copying the library files
info  current file: /var/folders/d5/9j9st5w90cj5867wwr1g299h0000gn/T/tmp-2995sGtEqzj5zr31/bower.json
info  copy to: /Users/petrgazarov/workspace/cdnjs/ajax/libs/trackpad-scroll-emulator/1.0.0/bower.json
info  current file: /var/folders/d5/9j9st5w90cj5867wwr1g299h0000gn/T/tmp-2995sGtEqzj5zr31/css
info  copy to: /Users/petrgazarov/workspace/cdnjs/ajax/libs/trackpad-scroll-emulator/1.0.0/css
info  current file: /var/folders/d5/9j9st5w90cj5867wwr1g299h0000gn/T/tmp-2995sGtEqzj5zr31/css/trackpad-scroll-emulator.css
info  copy to: /Users/petrgazarov/workspace/cdnjs/ajax/libs/trackpad-scroll-emulator/1.0.0/trackpad-scroll-emulator.css
info  current file: /var/folders/d5/9j9st5w90cj5867wwr1g299h0000gn/T/tmp-2995sGtEqzj5zr31/demo
info  copy to: /Users/petrgazarov/workspace/cdnjs/ajax/libs/trackpad-scroll-emulator/1.0.0/demo
info  current file: /var/folders/d5/9j9st5w90cj5867wwr1g299h0000gn/T/tmp-2995sGtEqzj5zr31/demo/css
info  copy to: /Users/petrgazarov/workspace/cdnjs/ajax/libs/trackpad-scroll-emulator/1.0.0/css
info  current file: /var/folders/d5/9j9st5w90cj5867wwr1g299h0000gn/T/tmp-2995sGtEqzj5zr31/demo/css/demo-fullscreen.css
info  copy to: /Users/petrgazarov/workspace/cdnjs/ajax/libs/trackpad-scroll-emulator/1.0.0/demo-fullscreen.css
info  current file: /var/folders/d5/9j9st5w90cj5867wwr1g299h0000gn/T/tmp-2995sGtEqzj5zr31/demo/css/demo.css
info  copy to: /Users/petrgazarov/workspace/cdnjs/ajax/libs/trackpad-scroll-emulator/1.0.0/demo.css
info  current file: /var/folders/d5/9j9st5w90cj5867wwr1g299h0000gn/T/tmp-2995sGtEqzj5zr31/demo/fullscreen-horiz.html
info  copy to: /Users/petrgazarov/workspace/cdnjs/ajax/libs/trackpad-scroll-emulator/1.0.0/fullscreen-horiz.html
info  current file: /var/folders/d5/9j9st5w90cj5867wwr1g299h0000gn/T/tmp-2995sGtEqzj5zr31/demo/fullscreen.html
info  copy to: /Users/petrgazarov/workspace/cdnjs/ajax/libs/trackpad-scroll-emulator/1.0.0/fullscreen.html
info  current file: /var/folders/d5/9j9st5w90cj5867wwr1g299h0000gn/T/tmp-2995sGtEqzj5zr31/demo/index.html
info  copy to: /Users/petrgazarov/workspace/cdnjs/ajax/libs/trackpad-scroll-emulator/1.0.0/index.html
info  current file: /var/folders/d5/9j9st5w90cj5867wwr1g299h0000gn/T/tmp-2995sGtEqzj5zr31/demo/js
info  copy to: /Users/petrgazarov/workspace/cdnjs/ajax/libs/trackpad-scroll-emulator/1.0.0/js
info  current file: /var/folders/d5/9j9st5w90cj5867wwr1g299h0000gn/T/tmp-2995sGtEqzj5zr31/demo/js/lib
info  copy to: /Users/petrgazarov/workspace/cdnjs/ajax/libs/trackpad-scroll-emulator/1.0.0/lib
info  current file: /var/folders/d5/9j9st5w90cj5867wwr1g299h0000gn/T/tmp-2995sGtEqzj5zr31/demo/js/lib/jquery-1.7.1.min.js
info  copy to: /Users/petrgazarov/workspace/cdnjs/ajax/libs/trackpad-scroll-emulator/1.0.0/jquery-1.7.1.min.js
info  current file: /var/folders/d5/9j9st5w90cj5867wwr1g299h0000gn/T/tmp-2995sGtEqzj5zr31/Gruntfile.js
info  copy to: /Users/petrgazarov/workspace/cdnjs/ajax/libs/trackpad-scroll-emulator/1.0.0/Gruntfile.js
info  current file: /var/folders/d5/9j9st5w90cj5867wwr1g299h0000gn/T/tmp-2995sGtEqzj5zr31/jquery.trackpad-scroll-emulator.js
info  copy to: /Users/petrgazarov/workspace/cdnjs/ajax/libs/trackpad-scroll-emulator/1.0.0/jquery.trackpad-scroll-emulator.js
info  current file: /var/folders/d5/9j9st5w90cj5867wwr1g299h0000gn/T/tmp-2995sGtEqzj5zr31/jquery.trackpad-scroll-emulator.min.js
info  copy to: /Users/petrgazarov/workspace/cdnjs/ajax/libs/trackpad-scroll-emulator/1.0.0/jquery.trackpad-scroll-emulator.min.js
info  current file: /var/folders/d5/9j9st5w90cj5867wwr1g299h0000gn/T/tmp-2995sGtEqzj5zr31/LICENSE
info  copy to: /Users/petrgazarov/workspace/cdnjs/ajax/libs/trackpad-scroll-emulator/1.0.0/LICENSE
info  current file: /var/folders/d5/9j9st5w90cj5867wwr1g299h0000gn/T/tmp-2995sGtEqzj5zr31/package.json
info  copy to: /Users/petrgazarov/workspace/cdnjs/ajax/libs/trackpad-scroll-emulator/1.0.0/package.json
info  current file: /var/folders/d5/9j9st5w90cj5867wwr1g299h0000gn/T/tmp-2995sGtEqzj5zr31/README.md
info  copy to: /Users/petrgazarov/workspace/cdnjs/ajax/libs/trackpad-scroll-emulator/1.0.0/README.md

I think it could be solved in tandem with https://github.com/cdnjs/cdnjs-importer/issues/29, where the importer only imports files that cdnjs can host... which would potentially solve this problem as well.

petrgazarov commented 7 years ago

@PeterDaveHello I think this is why there was a problem with sifter btw. There is a sifter.js file in bin/ in the source and when it was copying, it probably overrode sifter.js in the root.