Skip to content

Instantly share code, notes, and snippets.

@meeDamian
Created July 17, 2014 15:16
Show Gist options
  • Save meeDamian/0967871297f9bd313d01 to your computer and use it in GitHub Desktop.
Save meeDamian/0967871297f9bd313d01 to your computer and use it in GitHub Desktop.
'use strict'
path = require 'path'
yeoman = require 'yeoman-generator'
util = require 'util'
ngUtil = require '../util'
ScriptBase = require '../script-base'
class Generator extends ScriptBase
constructor: -> super arguments
askFor: ->
done = @async()
prompts = [
name: 'dir'
message: 'Where would you like to create this route?'
default: @config.get 'routeDirectory'
,
name: 'route'
message: 'What will the url of your route be?'
default: '/' + @name
]
@prompt prompts, (props) =>
{@route} = props
@dir = path.join props.dir, @name
done()
createFiles: ->
basePath = @config.get('basePath') or ''
@htmlUrl = ngUtil.relativeUrl basePath, path.join @dir, @name + '.html'
ngUtil.copyTemplates @, 'route'
module.exports = Generator
'use strict';
var path = require('path');
var yeoman = require('yeoman-generator');
var util = require('util');
var ngUtil = require('../util');
var ScriptBase = require('../script-base.js');
var Generator = module.exports = function Generator() {
ScriptBase.apply(this, arguments);
};
util.inherits(Generator, ScriptBase);
Generator.prototype.askFor = function askFor() {
var self = this;
var name = this.name;
var done = this.async();
var prompts = [
{
name: 'dir',
message: 'Where would you like to create this route?',
default: self.config.get('routeDirectory')
},
{
name: 'route',
message: 'What will the url of your route be?',
default: '/' + name
}
];
this.prompt(prompts, function (props) {
this.route = props.route;
this.dir = path.join(props.dir, this.name);
done();
}.bind(this));
};
Generator.prototype.createFiles = function createFiles() {
var basePath = this.config.get('basePath') || '';
this.htmlUrl = ngUtil.relativeUrl(basePath, path.join(this.dir, this.name + '.html'));
ngUtil.copyTemplates(this, 'route');
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment