16

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?

4 Answers 4

9
+50

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.

5

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.

2

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
1
  • 2
    It won't remove the script tag that the generator adds to app/index.html
    – rjoyal
    Jan 10, 2015 at 16:31
0

You can use the shell hack that rjoyal mentioned before, but remember to erase the script in te index.html file and the lines of code in app.js where says

.when('/myroute',{ 
templateUrl: 'views/myroute.html',
controller: 'myRouteCtrl' })

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.