gkz / grasp

JavaScript structural search, replace, and refactor
http://graspjs.com
MIT License
1.28k stars 33 forks source link

question: does grasp support any kind of file moving? #47

Open davestewart opened 9 years ago

davestewart commented 9 years ago

Specifically, I have many 100s of files in 30 or so folders, each with dependencies via require() on each other, and I need to move a whole bunch of folders around.

Is this possible, perhaps by some kind of grasp move src trg ?

Thanks, Dave

gkz commented 9 years ago

Not sure what you are asking exactly. There is the "--to" option: http://www.graspjs.com/docs/options/#to

davestewart commented 9 years ago

Hello.

No, actually. I wanted to know if Grasp could move files, but resolve any requires() as it does it:

// folder-a/somefile.js
require('./utility');

somefile.js then gets moved to folder-b, and its own requires are updated:

// folder-b/somefile.js
require('../folder-a/utility');

Make sense?

gkz commented 9 years ago

You could use grasp as a library, and pass a function as the replacement, and use node.js's fs module to check the path and change it to something else

http://www.graspjs.com/docs/lib/#replace