Skip to content
Permalink
Browse files
[Major] Removed unnecessary project name restriction (#859)
* removed unnecessary restriction that prevented project names from starting with a number. Project names starting with a number is perfectly valid.

* Reworded validateProjectName jsdoc

Co-Authored-By: Raphael von der Grün <raphinesse@gmail.com>

Co-authored-by: Raphael von der Grün <raphinesse@gmail.com>
  • Loading branch information
breautek and raphinesse committed Jan 7, 2020
1 parent 0e6ad28 commit 91d27161226291413835655016a4b0cc31e9449a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 28 deletions.
@@ -208,7 +208,7 @@ function validatePackageName (package_name) {
}

/**
* Test whether a project name is acceptable for use as an android class.
* Test whether given string is acceptable for use as a project name
* Returns a promise, fulfilled if the project name is acceptable; rejected
* otherwise.
*/
@@ -219,16 +219,6 @@ function validateProjectName (project_name) {
return Promise.reject(new CordovaError(msg + 'Project name cannot be empty'));
}

// Enforce stupid name error
if (project_name === 'CordovaActivity') {
return Promise.reject(new CordovaError(msg + 'Project name cannot be CordovaActivity'));
}

// Classes in Java don't begin with numbers
if (/^[0-9]/.test(project_name)) {
return Promise.reject(new CordovaError(msg + 'Project name must not begin with a number'));
}

return Promise.resolve();
}

@@ -79,7 +79,10 @@ describe('create', function () {
'mobilespec',
'package_name',
'PackageName',
'CordovaLib'
'CordovaLib',
'1337',
'3 Little Pigs',
'CordovaActivity'
];
valid.forEach(function (project_name) {
it('Test#003 : should accept ' + project_name, () => {
@@ -96,22 +99,6 @@ describe('create', function () {
expect(err.message).toContain('Project name cannot be empty');
});
});
it('should reject "CordovaActivity" as a project name', () => {
return create.validateProjectName('CordovaActivity').then(() => {
fail('Expected promise to be rejected');
}, err => {
expect(err).toEqual(jasmine.any(Error));
expect(err.message).toContain('Project name cannot be CordovaActivity');
});
});
it('should reject project names that begin with a number', () => {
return create.validateProjectName('1337').then(() => {
fail('Expected promise to be rejected');
}, err => {
expect(err).toEqual(jasmine.any(Error));
expect(err.message).toContain('Project name must not begin with a number');
});
});
});
});
describe('main method', function () {

0 comments on commit 91d2716

Please sign in to comment.