Merge "Consistent function spacing."

This commit is contained in:
Jenkins
2016-05-23 20:21:05 +00:00
committed by Gerrit Code Review
9 changed files with 81 additions and 81 deletions

View File

@@ -1,4 +1,4 @@
(function() { (function () {
'use strict'; 'use strict';
var yeoman = require('yeoman-generator'); var yeoman = require('yeoman-generator');
@@ -14,14 +14,14 @@
module.exports = yeoman.Base.extend({ module.exports = yeoman.Base.extend({
constructor: function() { constructor: function () {
yeoman.Base.apply(this, arguments); yeoman.Base.apply(this, arguments);
// Add support for a `--non-interactive` flag // Add support for a `--non-interactive` flag
this.option('non-interactive'); this.option('non-interactive');
}, },
initializing: function() { initializing: function () {
var done = this.async(); var done = this.async();
// Set our own defaults. // Set our own defaults.
@@ -37,12 +37,12 @@
.then(license.init) // Licensing .then(license.init) // Licensing
.then(eslint.init) // Linting .then(eslint.init) // Linting
.then(gitignore.init) // Gitignore .then(gitignore.init) // Gitignore
.then(function() { .then(function () {
done(); done();
}); });
}, },
prompting: function() { prompting: function () {
var done = this.async(); var done = this.async();
// Prompt components. // Prompt components.
@@ -53,12 +53,12 @@
.then(license.prompt) // Licensing .then(license.prompt) // Licensing
.then(eslint.prompt) // Linting .then(eslint.prompt) // Linting
.then(gitignore.prompt) // Gitignore .then(gitignore.prompt) // Gitignore
.then(function() { .then(function () {
done(); done();
}); });
}, },
configuring: function() { configuring: function () {
var done = this.async(); var done = this.async();
// Configure components. // Configure components.
@@ -69,19 +69,19 @@
.then(license.configure) // Licensing .then(license.configure) // Licensing
.then(eslint.configure) // Linting .then(eslint.configure) // Linting
.then(gitignore.configure) // Gitignore .then(gitignore.configure) // Gitignore
.then(function() { .then(function () {
done(); done();
}); });
}, },
writing: function() { writing: function () {
var self = this; var self = this;
var config = self.config.getAll(); var config = self.config.getAll();
var included = projectBuilder.getIncludedFiles(); var included = projectBuilder.getIncludedFiles();
var excluded = projectBuilder.getExcludedFiles(); var excluded = projectBuilder.getExcludedFiles();
// Write out all files included in the project builder. // Write out all files included in the project builder.
included.forEach(function(fileRef) { included.forEach(function (fileRef) {
if (fileRef.hasOwnProperty('content')) { if (fileRef.hasOwnProperty('content')) {
var content = typeof fileRef.content === 'function' var content = typeof fileRef.content === 'function'
? "" + fileRef.content() ? "" + fileRef.content()
@@ -97,7 +97,7 @@
}); });
// Delete all files explicitly excluded in the project builder. // Delete all files explicitly excluded in the project builder.
excluded.forEach(function(path) { excluded.forEach(function (path) {
self.fs.delete(self.destinationPath(path)); self.fs.delete(self.destinationPath(path));
}); });
} }

View File

@@ -1,4 +1,4 @@
(function() { (function () {
'use strict'; 'use strict';
var projectBuilder = require('../project_builder'); var projectBuilder = require('../project_builder');

View File

@@ -1,4 +1,4 @@
(function() { (function () {
'use strict'; 'use strict';
var projectBuilder = require('../project_builder'); var projectBuilder = require('../project_builder');
@@ -33,7 +33,7 @@
if (fs.exists(ignoreFile)) { if (fs.exists(ignoreFile)) {
excludedPaths = fs.read(ignoreFile) excludedPaths = fs.read(ignoreFile)
.split('\n') .split('\n')
.filter(function(item) { .filter(function (item) {
// Remove empty lines. // Remove empty lines.
return item.length > 0; return item.length > 0;
}); });

View File

@@ -1,4 +1,4 @@
(function() { (function () {
'use strict'; 'use strict';
var projectBuilder = require('../project_builder'); var projectBuilder = require('../project_builder');

View File

@@ -1,4 +1,4 @@
(function() { (function () {
'use strict'; 'use strict';
var pkgBuilder = require('../pkg_builder'); var pkgBuilder = require('../pkg_builder');

View File

@@ -1,4 +1,4 @@
(function() { (function () {
'use strict'; 'use strict';
var path = require('path'); var path = require('path');
var assert = require('yeoman-assert'); var assert = require('yeoman-assert');
@@ -8,16 +8,16 @@
var modules = ['gerrit', 'license', 'editorconfig']; var modules = ['gerrit', 'license', 'editorconfig'];
var projectBuilder = require('../../generators/app/lib/project_builder'); var projectBuilder = require('../../generators/app/lib/project_builder');
describe('generator-openstack:app', function() { describe('generator-openstack:app', function () {
beforeEach(function() { beforeEach(function () {
projectBuilder.clear(); projectBuilder.clear();
}); });
it('should call all module lifecycle prompts', it('should call all module lifecycle prompts',
function(done) { function (done) {
var spies = []; var spies = [];
modules.forEach(function(name) { modules.forEach(function (name) {
var module = require('../../generators/app/lib/component/' + name); var module = require('../../generators/app/lib/component/' + name);
spies.push(spyOn(module, 'init').and.callThrough()); spies.push(spyOn(module, 'init').and.callThrough());
spies.push(spyOn(module, 'prompt').and.callThrough()); spies.push(spyOn(module, 'prompt').and.callThrough());
@@ -25,8 +25,8 @@
}); });
helpers.run(generator) helpers.run(generator)
.on('end', function() { .on('end', function () {
spies.forEach(function(spy) { spies.forEach(function (spy) {
expect(spy.calls.any()).toBeTruthy(); expect(spy.calls.any()).toBeTruthy();
}); });
@@ -34,44 +34,44 @@
}); });
}); });
describe('writing()', function() { describe('writing()', function () {
it('should create all files created in the project builder', it('should create all files created in the project builder',
function(done) { function (done) {
helpers.run(generator) helpers.run(generator)
.on('end', function() { .on('end', function () {
assert.file(['.gitreview']); // We'll just use a file we know about. assert.file(['.gitreview']); // We'll just use a file we know about.
done(); done();
}); });
}); });
it('should write any files provided to the content builder', it('should write any files provided to the content builder',
function(done) { function (done) {
projectBuilder.writeFile('test.json', function() { projectBuilder.writeFile('test.json', function () {
return 'foo'; return 'foo';
}); });
projectBuilder.writeFile('test_null.json', function() { projectBuilder.writeFile('test_null.json', function () {
// do nothing. // do nothing.
}); });
projectBuilder.writeFile('test_empty.json', function() { projectBuilder.writeFile('test_empty.json', function () {
return ''; return '';
}); });
projectBuilder.writeFile('test_static.json', 'static_content'); projectBuilder.writeFile('test_static.json', 'static_content');
projectBuilder.writeFile('test_undefined.json'); projectBuilder.writeFile('test_undefined.json');
helpers.run(generator) helpers.run(generator)
.on('end', function() { .on('end', function () {
assert.file(['test.json', 'test_static.json','test_empty.json', 'test_null.json', assert.file(['test.json', 'test_static.json', 'test_empty.json', 'test_null.json',
'test_undefined.json']); 'test_undefined.json']);
done(); done();
}); });
}); });
it('should delete all files flagged in the project builder', it('should delete all files flagged in the project builder',
function(done) { function (done) {
projectBuilder.removeFile('test.json'); projectBuilder.removeFile('test.json');
helpers.run(generator) helpers.run(generator)
.on('end', function() { .on('end', function () {
assert.noFile(['test.json']); assert.noFile(['test.json']);
done(); done();
}); });

View File

@@ -1,4 +1,4 @@
(function() { (function () {
'use strict'; 'use strict';
var libDir = '../../../../generators/app/lib'; var libDir = '../../../../generators/app/lib';
var mockGenerator; var mockGenerator;
@@ -9,22 +9,22 @@
var mocks = require('../../../helpers/mocks'); var mocks = require('../../../helpers/mocks');
var yaml = require('js-yaml'); var yaml = require('js-yaml');
describe('generator-openstack:lib/component/eslint', function() { describe('generator-openstack:lib/component/eslint', function () {
beforeEach(function() { beforeEach(function () {
mockGenerator = mocks.buildGenerator(); mockGenerator = mocks.buildGenerator();
mockGenerator.fs.write('.eslintignore', mockEslintIgnore.join('\n')); mockGenerator.fs.write('.eslintignore', mockEslintIgnore.join('\n'));
projectBuilder.clear(); projectBuilder.clear();
}); });
it('should define init, prompt, and configure', it('should define init, prompt, and configure',
function() { function () {
expect(typeof eslint.init).toBe('function'); expect(typeof eslint.init).toBe('function');
expect(typeof eslint.prompt).toBe('function'); expect(typeof eslint.prompt).toBe('function');
expect(typeof eslint.configure).toBe('function'); expect(typeof eslint.configure).toBe('function');
}); });
describe('init()', function() { describe('init()', function () {
it('should return a generator', it('should return a generator',
function () { function () {
var outputGenerator = eslint.init(mockGenerator); var outputGenerator = eslint.init(mockGenerator);
@@ -32,14 +32,14 @@
}); });
it('should not interact with config', it('should not interact with config',
function() { function () {
var spy = spyOn(mockGenerator.config, 'defaults'); var spy = spyOn(mockGenerator.config, 'defaults');
eslint.init(mockGenerator); eslint.init(mockGenerator);
expect(spy.calls.any()).toBeFalsy(); expect(spy.calls.any()).toBeFalsy();
}); });
}); });
describe('prompt()', function() { describe('prompt()', function () {
it('should return a generator', it('should return a generator',
function () { function () {
var outputGenerator = eslint.prompt(mockGenerator); var outputGenerator = eslint.prompt(mockGenerator);
@@ -47,14 +47,14 @@
}); });
it('should do nothing', it('should do nothing',
function() { function () {
var spy = spyOn(mockGenerator, 'prompt'); var spy = spyOn(mockGenerator, 'prompt');
eslint.prompt(mockGenerator); eslint.prompt(mockGenerator);
expect(spy.calls.any()).toBeFalsy(); expect(spy.calls.any()).toBeFalsy();
}); });
}); });
describe('configure()', function() { describe('configure()', function () {
it('should return a generator', it('should return a generator',
function () { function () {
var outputGenerator = eslint.configure(mockGenerator); var outputGenerator = eslint.configure(mockGenerator);
@@ -62,7 +62,7 @@
}); });
it('should add .eslintrc and .eslintignore to the project files.', it('should add .eslintrc and .eslintignore to the project files.',
function() { function () {
eslint.configure(mockGenerator); eslint.configure(mockGenerator);
var files = projectBuilder.getIncludedFiles(); var files = projectBuilder.getIncludedFiles();
@@ -72,14 +72,14 @@
}); });
}); });
describe('.eslintrc management', function() { describe('.eslintrc management', function () {
var mockEslintRc = { var mockEslintRc = {
extends: 'openstack', extends: 'openstack',
plugins: ['angular'] plugins: ['angular']
}; };
it('should write a .eslintrc file as valid .yaml', it('should write a .eslintrc file as valid .yaml',
function() { function () {
eslint.init(mockGenerator); eslint.init(mockGenerator);
eslint.configure(mockGenerator); eslint.configure(mockGenerator);
@@ -91,7 +91,7 @@
}); });
it('should echo back existing .eslintrc', it('should echo back existing .eslintrc',
function() { function () {
var yamlContent = yaml.safeDump(mockEslintRc); var yamlContent = yaml.safeDump(mockEslintRc);
mockGenerator.fs.write('.eslintrc', yamlContent); mockGenerator.fs.write('.eslintrc', yamlContent);
@@ -105,7 +105,7 @@
}); });
it('should convert a json .eslintrc to yaml', it('should convert a json .eslintrc to yaml',
function() { function () {
mockGenerator.fs.write('.eslintrc', JSON.stringify(mockEslintRc)); mockGenerator.fs.write('.eslintrc', JSON.stringify(mockEslintRc));
eslint.init(mockGenerator); eslint.init(mockGenerator);
@@ -118,10 +118,10 @@
}); });
}); });
describe('.eslintignore management', function() { describe('.eslintignore management', function () {
it('should echo back existing .eslintignore', it('should echo back existing .eslintignore',
function() { function () {
mockGenerator.fs.write('.eslintignore', mockEslintIgnore.join('\n')); mockGenerator.fs.write('.eslintignore', mockEslintIgnore.join('\n'));
eslint.init(mockGenerator); eslint.init(mockGenerator);
@@ -132,13 +132,13 @@
var ignoreContent = ignoreRef.content().split('\n'); var ignoreContent = ignoreRef.content().split('\n');
expect(ignoreContent.length).toBe(mockEslintIgnore.length); expect(ignoreContent.length).toBe(mockEslintIgnore.length);
ignoreContent.forEach(function(item) { ignoreContent.forEach(function (item) {
expect(mockEslintIgnore.indexOf(item)).not.toBe(-1); expect(mockEslintIgnore.indexOf(item)).not.toBe(-1);
}); });
}); });
it('should sort the ignored files.', it('should sort the ignored files.',
function() { function () {
mockGenerator.fs.write('.eslintignore', mockEslintIgnore.join('\n')); mockGenerator.fs.write('.eslintignore', mockEslintIgnore.join('\n'));
eslint.init(mockGenerator); eslint.init(mockGenerator);
@@ -153,7 +153,7 @@
}); });
it('should remove any whitespace from the existing .eslintignore', it('should remove any whitespace from the existing .eslintignore',
function() { function () {
mockGenerator.fs.write('.eslintignore', ['1_one', '', '2_two', ''].join('\n')); mockGenerator.fs.write('.eslintignore', ['1_one', '', '2_two', ''].join('\n'));
eslint.init(mockGenerator); eslint.init(mockGenerator);
@@ -167,7 +167,7 @@
expect(ignoreContent[1]).toBe('2_two'); expect(ignoreContent[1]).toBe('2_two');
}); });
it('should delete the file if there\'s nothing to ignore', function() { it('should delete the file if there\'s nothing to ignore', function () {
mockGenerator.fs.write('.eslintignore', ''); mockGenerator.fs.write('.eslintignore', '');
eslint.init(mockGenerator); eslint.init(mockGenerator);

View File

@@ -1,4 +1,4 @@
(function() { (function () {
'use strict'; 'use strict';
var libDir = '../../../../generators/app/lib'; var libDir = '../../../../generators/app/lib';
@@ -8,59 +8,59 @@
var mocks = require('../../../helpers/mocks'); var mocks = require('../../../helpers/mocks');
var mockGenerator; var mockGenerator;
describe('generator-openstack:lib/component/license', function() { describe('generator-openstack:lib/component/license', function () {
beforeEach(function() { beforeEach(function () {
mockGenerator = mocks.buildGenerator(); mockGenerator = mocks.buildGenerator();
projectBuilder.clear(); projectBuilder.clear();
}); });
it('should define init, prompt, and configure', it('should define init, prompt, and configure',
function() { function () {
expect(typeof license.init).toBe('function'); expect(typeof license.init).toBe('function');
expect(typeof license.prompt).toBe('function'); expect(typeof license.prompt).toBe('function');
expect(typeof license.configure).toBe('function'); expect(typeof license.configure).toBe('function');
}); });
describe('init()', function() { describe('init()', function () {
it('should return a generator', it('should return a generator',
function() { function () {
var outputGenerator = license.init(mockGenerator); var outputGenerator = license.init(mockGenerator);
expect(outputGenerator).toEqual(mockGenerator); expect(outputGenerator).toEqual(mockGenerator);
}); });
it('should do nothing', it('should do nothing',
function() { function () {
var spy = spyOn(mockGenerator.config, 'defaults'); var spy = spyOn(mockGenerator.config, 'defaults');
license.init(mockGenerator); license.init(mockGenerator);
expect(spy.calls.any()).toBeFalsy(); expect(spy.calls.any()).toBeFalsy();
}); });
}); });
describe('prompt()', function() { describe('prompt()', function () {
it('should return a generator', it('should return a generator',
function() { function () {
var outputGenerator = license.prompt(mockGenerator); var outputGenerator = license.prompt(mockGenerator);
expect(outputGenerator).toEqual(mockGenerator); expect(outputGenerator).toEqual(mockGenerator);
}); });
it('should do nothing', it('should do nothing',
function() { function () {
var spy = spyOn(mockGenerator, 'prompt'); var spy = spyOn(mockGenerator, 'prompt');
license.prompt(mockGenerator); license.prompt(mockGenerator);
expect(spy.calls.any()).toBeFalsy(); expect(spy.calls.any()).toBeFalsy();
}); });
}); });
describe('configure()', function() { describe('configure()', function () {
it('should return a generator', it('should return a generator',
function() { function () {
var outputGenerator = license.configure(mockGenerator); var outputGenerator = license.configure(mockGenerator);
expect(outputGenerator).toEqual(mockGenerator); expect(outputGenerator).toEqual(mockGenerator);
}); });
it('should add license to the project files.', it('should add license to the project files.',
function() { function () {
license.configure(mockGenerator); license.configure(mockGenerator);
var files = projectBuilder.getIncludedFiles(); var files = projectBuilder.getIncludedFiles();
@@ -70,7 +70,7 @@
}); });
it('should add license to the package.json files.', it('should add license to the package.json files.',
function() { function () {
license.configure(mockGenerator); license.configure(mockGenerator);
var parsedResult = JSON.parse(pkgBuilder.toJSON()); var parsedResult = JSON.parse(pkgBuilder.toJSON());

View File

@@ -1,4 +1,4 @@
(function() { (function () {
'use strict'; 'use strict';
var libDir = '../../../../generators/app/lib'; var libDir = '../../../../generators/app/lib';
@@ -8,29 +8,29 @@
var mocks = require('../../../helpers/mocks'); var mocks = require('../../../helpers/mocks');
var mockGenerator; var mockGenerator;
describe('generator-openstack:lib/component/pkg', function() { describe('generator-openstack:lib/component/pkg', function () {
beforeEach(function() { beforeEach(function () {
mockGenerator = mocks.buildGenerator(); mockGenerator = mocks.buildGenerator();
projectBuilder.clear(); projectBuilder.clear();
}); });
it('should define init, prompt, and configure', it('should define init, prompt, and configure',
function() { function () {
expect(typeof pkg.init).toBe('function'); expect(typeof pkg.init).toBe('function');
expect(typeof pkg.prompt).toBe('function'); expect(typeof pkg.prompt).toBe('function');
expect(typeof pkg.configure).toBe('function'); expect(typeof pkg.configure).toBe('function');
}); });
describe('init()', function() { describe('init()', function () {
it('should return a generator', it('should return a generator',
function() { function () {
var outputGenerator = pkg.init(mockGenerator); var outputGenerator = pkg.init(mockGenerator);
expect(outputGenerator).toEqual(mockGenerator); expect(outputGenerator).toEqual(mockGenerator);
}); });
it('should read an existing package.json file into the package builder', it('should read an existing package.json file into the package builder',
function() { function () {
mockGenerator.fs.writeJSON("package.json", {name: "foo"}); mockGenerator.fs.writeJSON("package.json", {name: "foo"});
pkg.init(mockGenerator); pkg.init(mockGenerator);
@@ -39,30 +39,30 @@
}); });
}); });
describe('prompt()', function() { describe('prompt()', function () {
it('should return a generator', it('should return a generator',
function() { function () {
var outputGenerator = pkg.prompt(mockGenerator); var outputGenerator = pkg.prompt(mockGenerator);
expect(outputGenerator).toEqual(mockGenerator); expect(outputGenerator).toEqual(mockGenerator);
}); });
it('should do nothing', it('should do nothing',
function() { function () {
var spy = spyOn(mockGenerator, 'prompt'); var spy = spyOn(mockGenerator, 'prompt');
pkg.prompt(mockGenerator); pkg.prompt(mockGenerator);
expect(spy.calls.any()).toBeFalsy(); expect(spy.calls.any()).toBeFalsy();
}); });
}); });
describe('configure()', function() { describe('configure()', function () {
it('should return a generator', it('should return a generator',
function() { function () {
var outputGenerator = pkg.configure(mockGenerator); var outputGenerator = pkg.configure(mockGenerator);
expect(outputGenerator).toEqual(mockGenerator); expect(outputGenerator).toEqual(mockGenerator);
}); });
it('should add package.json to the project files.', it('should add package.json to the project files.',
function() { function () {
pkg.configure(mockGenerator); pkg.configure(mockGenerator);
var files = projectBuilder.getIncludedFiles(); var files = projectBuilder.getIncludedFiles();