Search code examples
node.jsyeomanyeoman-generator

Copy files from GitHub using remote() and copy to directory while being able to excluding some files


I want to be able to pull files from a GitHub zip file using remote() or something similar and then copy the files to a directory. I want to also be able to exclude some files from being copied, which could be by means of an array.

For example: I want to get the master version of laravel (github.com/laravel/laravel) and copy over all the files apart from this array:

['.gitignore', 'readme.md', 'CONTRIBUTING.md', 'phpunit.xml', 'package.json', 'gulpfile.js', 'public/css', 'public/fonts', 'public/favicon.ico']

What is the best way to achieve this?


Solution

  • Use the mem-fs-editor glob helpers to match and ignore patterns while copying the files over.

    You can probably fetch your git repo using npm (package.json dependencies with git), this will make easier to use.