Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to delete/remove a scaffolded route generated in Yeoman Angular

I know I could just delete the code and files; however, is there a way to remove a generated route in yeoman - angular in a similar automated command?

e.g. yo angular:route myroute is how you generate it

What is the cmd line code I would run to remove, rollback, or delete this scaffolding of a route?

like image 285
Armeen Harwood Avatar asked Jan 01 '14 02:01

Armeen Harwood


3 Answers

I think there is not command for do it.

I read the documentation (http://yeoman.io/generators.html#writing-your-first-generator) about generators and subgenerators and I can't find anything about removing process.

I read also documentation about generator API (http://yeoman.github.io/generator/actions.html) and there are options like copy, directory, read and write but still nothing about removing. So I think it's not possible even write your own command for these generators.

like image 167
WooCaSh Avatar answered Nov 20 '22 19:11

WooCaSh


Coming from a Rails background even I tried to remove the routes but there doesn't seem to be any method to do so. I've looked through the docs. And there doesn't seem to be any plan to add iy.

Anyway when we generate the files we see which files are generated so all we have to do is delete those.

yo angular:route route1 creates 3 files

app/scripts/controllers/route1.js              (controller)
app/views/route1.html                          (view)
app/test/spec/controllers/route1.js            (testing the controller)

For the other generators:

yo angular:controller user                app/scripts/controllers/user.js

yo angular:directive myDirective          app/scripts/directives/myDirective.js

yo angular:filter myFilter                app/scripts/filters/myFilter.js

yo angular:view user                      app/views/user.html

yo angular:service myService              app/scripts/services/myService.js

yo angular:decorator serviceName          app/scripts/decorators/serviceNameDecorator.js

yo angular:controller user --coffee       app/scripts/controller/user.coffee 

Tests are also generated along side.

like image 5
kartikluke Avatar answered Nov 20 '22 21:11

kartikluke


Here is a shell hack that I have been using.

$ yo angular:controller testcontroller
    create app/scripts/controllers/testcontroller.js
    create test/spec/controllers/testcontroller.js
$ rm -v `yo angular:controller testcontroller 2>&1 | awk '{print $2}'`
app/scripts/controllers/testcontroller.js
test/spec/controllers/testcontroller.js
like image 2
rjoyal Avatar answered Nov 20 '22 20:11

rjoyal