Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How should I move or delete files in a Yeoman Generator?

I'm building a generator that in part includes scaffolding from another project created with exec. Depending on user input I need to move or delete parts of this scaffolding.

Right now I'm doing it with node's fs.child_process.spawn and shelljs, but seeing as the Yo generator has mkdir, write, template, and copy, I'm wondering if there's a Yo way to move or delete files and directories.

like image 360
RobW Avatar asked Apr 28 '13 02:04

RobW


2 Answers

Yeoman now supports this via the fs API, which is an in memory filesystem implementation.

this.fs.move('source/file', 'dest/file'); this.fs.copy('source', 'dest');

File System Docs

like image 130
Selvin Ortiz Avatar answered Oct 07 '22 03:10

Selvin Ortiz


Still not documented, but this is the delete method (works for me):

this.fs.delete('file/to/delete');

Link: Yeoman issue 1505

like image 30
StampyCode Avatar answered Oct 07 '22 01:10

StampyCode