Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added controller cmd

  • Loading branch information...
commit d0220766e4eb8b350a06234c0e7c7860d0f840fb 1 parent 7b9494e
@twilson63 authored
View
17 cmd/controller.js
@@ -0,0 +1,17 @@
+var ejs = require('ejs'),
+ fs = require('fs'),
+ path = require('path');
+
+var templateDir = __dirname + '/../template';
+
+module.exports = function(name, cb) {
+ // generate controllerjs
+ var templates = ['app/scripts/controllers/index.js.ejs','app/views/index.html.ejs'];
+ templates.forEach(function(item){
+ var ctrl = item.replace('index', name),
+ ejsTemplate = fs.readFileSync(path.join(templateDir, ctrl)),
+ result = ejs.render(ejsTemplate.toString(), data);
+ fs.writeFileSync(path.join(name, item.replace('.ejs', '')), result);
+ });
+ cb(null);
+}
View
0  cmd/directive.js
No changes.
View
24 cmd/init.js
@@ -19,23 +19,23 @@ module.exports = function(name, cb) {
console.log('project already exists!');
return;
}
+ var data = {
+ name: name,
+ title: name,
+ version: "0.0.0",
+ bootstrap: conf.generator.bootstrap,
+ fontawesome: conf.generator.fontawesome,
+ jquery: conf.generator.jquery,
+ bootstrapjs: conf.generator.bootstrapjs,
+ angularjs: conf.generator.angularjs
+ };
// create project directory
fs.mkdirSync(name);
wrench.readdirSyncRecursive(templateDir).forEach(
function(item){
if(/.ejs$/.test(item)) {
- var ejsTemplate = fs.readFileSync(path.join(templateDir, item));
- var result = ejs.render(ejsTemplate.toString(), {
- name: name,
- title: name,
- version: "0.0.0",
- bootstrap: conf.generator.bootstrap,
- fontawesome: conf.generator.fontawesome,
- jquery: conf.generator.jquery,
- bootstrapjs: conf.generator.bootstrapjs,
- angularjs: conf.generator.angularjs
- }
- );
+ var ejsTemplate = fs.readFileSync(path.join(templateDir, item)),
+ result = ejs.render(ejsTemplate.toString(), data);
fs.writeFileSync(path.join(name, item.replace('.ejs', '')), result);
} else {
mkdirp(path.join(name, item));
View
0  cmd/service.js
No changes.
View
7 index.js
@@ -10,8 +10,11 @@ app.use(flatiron.plugins.cli, {
'',
'Commands:',
'version - returns the version',
- 'init - creates a basic angular app structure',
- 'g - generates new [controller, view, resource, etc]'
+ 'init [name] - creates a basic angular app structure',
+ 'controller [name] - generates new controller',
+ 'directive [name] - generates new directive',
+ 'service [name] - generates new service'
+
]
});
app.start();
Please sign in to comment.
Something went wrong with that request. Please try again.