Skip to content

appname should be shared by all generators and should not contain alphanum chars #122

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 16, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ function Base(args, options, config) {
// holder for conflicting states
this._conflicts = [];

// application name without non-alphanums
this.appname = path.basename( process.cwd() ).replace(/[^\w\s]+?/g, ' ');

// init general options, these are common to all generators
this.option('help', {
alias: 'h',
Expand Down
1 change: 0 additions & 1 deletion lib/generators/angular/all/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ var Generator = module.exports = function Generator() {
yeoman.generators.Base.apply(this, arguments);

this.option('coffee');
this.appname = path.basename(process.cwd());

var args = ['main'];

Expand Down
1 change: 0 additions & 1 deletion lib/generators/angular/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ module.exports = Generator;

function Generator() {
ScriptBase.apply(this, arguments);
this.appname = path.basename(process.cwd());
}

util.inherits(Generator, ScriptBase);
Expand Down
1 change: 0 additions & 1 deletion lib/generators/angular/common/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ module.exports = Generator;

function Generator() {
yeoman.generators.Base.apply(this, arguments);
this.appname = path.basename(process.cwd());
}

util.inherits(Generator, yeoman.generators.Base);
Expand Down
1 change: 0 additions & 1 deletion lib/generators/angular/directive/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ module.exports = Generator;
function Generator() {
ScriptBase.apply(this, arguments);

this.appname = path.basename(process.cwd());
}

util.inherits(Generator, ScriptBase);
Expand Down
1 change: 0 additions & 1 deletion lib/generators/angular/filter/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ function Generator() {
ScriptBase.apply(this, arguments);
this.sourceRoot(path.join(__dirname, '../templates'));

this.appname = path.basename(process.cwd());
}

util.inherits(Generator, ScriptBase);
Expand Down
1 change: 0 additions & 1 deletion lib/generators/angular/route/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ function Generator() {
yeoman.generators.NamedBase.apply(this, arguments);
this.sourceRoot(path.join(__dirname, '../templates'));

this.appname = path.basename(process.cwd());

this.hookFor('angular:controller', {
args: [this.name]
Expand Down
1 change: 0 additions & 1 deletion lib/generators/angular/script-base.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ module.exports = Generator;

function Generator() {
yeoman.generators.NamedBase.apply(this, arguments);
this.appname = path.basename(process.cwd());


this.option('coffee');
Expand Down
1 change: 0 additions & 1 deletion lib/generators/angular/service/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ function Generator() {
this.type = 'factory';
}

this.appname = path.basename(process.cwd());
}

util.inherits(Generator, ScriptBase);
Expand Down
1 change: 0 additions & 1 deletion lib/generators/angular/view/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ function Generator() {
yeoman.generators.NamedBase.apply(this, arguments);
this.sourceRoot(path.join(__dirname, '../templates'));

this.appname = path.basename(process.cwd());
}

util.inherits(Generator, yeoman.generators.NamedBase);
Expand Down
1 change: 0 additions & 1 deletion lib/generators/backbone/all/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ function Generator() {
this.dirs = 'models collections views routes helpers templates'.split(' ');

this.option('coffee');
this.appname = path.basename(process.cwd());

var args = [ 'application' ];

Expand Down
1 change: 0 additions & 1 deletion lib/generators/backbone/collection/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ function Generator() {
this.sourceRoot(path.join(__dirname, dirPath));

// required for collection.js template which uses `appname`
this.appname = path.basename(process.cwd());
}

util.inherits(Generator, yeoman.generators.NamedBase);
Expand Down
1 change: 0 additions & 1 deletion lib/generators/backbone/model/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ function Generator() {
};
});

this.appname = path.basename(process.cwd());
}

util.inherits(Generator, yeoman.generators.NamedBase);
Expand Down
1 change: 0 additions & 1 deletion lib/generators/backbone/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ function Generator() {
this.sourceRoot(path.join(__dirname, dirPath));

// required for router.js template which uses `appname`
this.appname = path.basename(process.cwd());
}

util.inherits(Generator, yeoman.generators.NamedBase);
Expand Down
1 change: 0 additions & 1 deletion lib/generators/backbone/view/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ function Generator() {
var dirPath = this.options.coffee ? '../templates/coffeescript/' : '../templates';
this.sourceRoot(path.join(__dirname, dirPath));

this.appname = path.basename(process.cwd());
}

util.inherits(Generator, yeoman.generators.NamedBase);
Expand Down
1 change: 0 additions & 1 deletion lib/generators/chromeapp/all/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ module.exports = Generator;
function Generator() {
yeoman.generators.Base.apply( this, arguments );
this.sourceRoot( path.join( __dirname, 'templates' ) );
this.appname = path.basename( process.cwd() );
this.appPermissions = {
};
}
Expand Down
1 change: 0 additions & 1 deletion lib/generators/ember-starter/all/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ function Generator() {
yeoman.generators.Base.apply(this, arguments);
this.sourceRoot(path.join(__dirname, '../templates'));
this.dirs = 'scripts styles'.split(' ');
this.appname = path.basename(process.cwd());
}

util.inherits(Generator, yeoman.generators.Base);
Expand Down
1 change: 0 additions & 1 deletion lib/generators/ember/all/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ function Generator() {
args: [ 'application' ]
});

this.appname = path.basename(process.cwd());
}

util.inherits(Generator, yeoman.generators.Base);
Expand Down
1 change: 0 additions & 1 deletion lib/generators/ember/controller/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ function Generator() {
desc: 'Create an Ember.ArrayController to represent multiple objects'
});

this.appname = path.basename(process.cwd());

this.filename = _.dasherize(this.name).replace(/^-/, '');
}
Expand Down
1 change: 0 additions & 1 deletion lib/generators/ember/model/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ function Generator() {
};
});

this.appname = path.basename(process.cwd());
}

util.inherits(Generator, yeoman.generators.NamedBase);
Expand Down
1 change: 0 additions & 1 deletion lib/generators/ember/view/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ function Generator() {
yeoman.generators.NamedBase.apply(this, arguments);
this.sourceRoot(path.join(__dirname, '../templates'));

this.appname = path.basename(process.cwd());
}

util.inherits(Generator, yeoman.generators.NamedBase);
Expand Down
Empty file added lib/util/misc.js
Empty file.
5 changes: 5 additions & 0 deletions test/temp.dev/Gruntfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = function(grunt) {
grunt.initConfig({
"dummy": true
});
};
25 changes: 25 additions & 0 deletions test/temp.dev/test/generators/test-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

var path = require('path');
var helpers = require('yeoman-generators').test;

describe('Test generator test', function() {
before(helpers.before(path.join(__dirname, './temp')));

it('runs sucessfully', function(done) {
helpers.runGenerator('test', done);
});

it('creates expected files', function() {

// Use helpers.assertFile() to help you test the output of your generator
//
// Example:
//
// // check file exists
// helpers.assertFile('app/model/post.js');
// // Check content
// helpers.assertFile('app/model/post.js', /Backbone\.model/);
it('should create expected files');

});
});
8 changes: 7 additions & 1 deletion test/test-base.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ var fs = require('fs'),
generators = require('..');

describe('yeoman.generators.Base', function() {
before(generators.test.before(path.join(__dirname, 'temp')));
before(generators.test.before(path.join(__dirname, 'temp.dev')));

before(function() {
function Dummy() {
Expand All @@ -31,6 +31,12 @@ describe('yeoman.generators.Base', function() {
this.generator = generators.setup(grunt).create('generator', ['test'], {}, {});
});

describe('generator.appname', function() {
it('should be set with the project directory name without non-alphanums', function() {
assert.equal( this.dummy.appname, "temp dev" );
});
});

describe('generator.run(args, cb)', function() {
it('should run all methods in the given generator', function() {
this.dummy.run();
Expand Down