globyeomanyeoman-generator

Is it possible to ignore files when copying directories in a yeoman generator?


I'm trying to write a yeoman generator and at one point I need to copy the files/folders of a github repo to the current working directory, eg:

this.remote('owner', 'repo', function (err, remote) {
    remote.directory('.', '.');
});

However I want to ignore some of the files in this repo, is it possible to do so? I found the function responsible for this but it doesn't seem to be a clear way to do it, there's a process function that you can pass but I'm not sure if you can "cancel" a file being copied if it matches a certain pattern.


Solution

  • You should rely on the this.fs object rather than the old depreciated files methods.

    Helper methods on this.fs support glob patterns, so ignoring some files become trivial.

    You can learn more about Yeoman file system here: http://yeoman.io/authoring/file-system.html