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

remove files with this.fs.delete #1505

Closed
dzuluaga opened this issue May 11, 2015 · 5 comments
Closed

remove files with this.fs.delete #1505

dzuluaga opened this issue May 11, 2015 · 5 comments

Comments

@dzuluaga
Copy link

Hi there, I'm trying to remove files from a folder. However, nothing happens. Files are never removed. They can be removed though, if they exist under root folder. Am I missing anything?

  removeDir : function() {
      this.fs.delete('./grunt/*.js'); //tried grunt/*js, grunt/**/*.js
  },
@kevva
Copy link
Member

kevva commented May 11, 2015

Try this:

removeDir : function() {
  this.fs.delete('grunt/**/*.js');
}

@SBoudrias
Copy link
Member

They can be removed though, if they exist under root folder.

What do you mean?

@dzuluaga
Copy link
Author

Thanks, @kevva. It looks when the function executes in the default priority (#2), the files aren't been copied over yet, so no files are removed. However, when I move the removeDir function to the end priority (#1), it works fine. Is there a way to force the execution of a function within the default priority after another function has been executed? so when the files have been already copied.

//#1 function as part of end priority - works as expected
module.exports = yeoman.generators.Base.extend({
  //...default priority
  grunt: function() {
    this.bulkDirectory('grunt', 'grunt');
  },
  end : { // end priority
    removeDir: function () {
        this.fs.delete('grunt/**/apigee-config.js');
    }
  }
});
//#2 function as part of default priority - it doesn't remove files
module.exports = yeoman.generators.Base.extend({
  grunt: function() {
    this.bulkDirectory('grunt', 'grunt');
  },
  removeDir: function () {
      this.fs.delete('grunt/**/apigee-config.js');
 }
});

@dzuluaga
Copy link
Author

@kevva and @SBoudrias I think somewhere along the lines of managing Yeoman Grunfile should help me to figure this out. However, The one on the page doesn't provide an end-to-end example.
Any chance where I can find one? Thanks!

@SBoudrias
Copy link
Member

Is there a way to force the execution of a function within the default priority after another function has been executed?

No, when composing, your generators should be context agnostic. They should be standalone and not depends on each other. If you don't want to generate these files, instead of deleting them after creation, pass an option to the sub-generator to not generate them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants