Skip to content

Commit

Permalink
fix(init): the cordova-id flag for corber init was broken, fixes #675
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorhummon committed Nov 25, 2020
1 parent 1f189bc commit f876db2
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 9 deletions.
2 changes: 1 addition & 1 deletion lib/commands/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ module.exports = Command.extend({

availableOptions: [
{ name: 'name', type: String },
{ name: 'cordovaid', type: String },
{ name: 'cordova-id', type: String },
{ name: 'template-path', type: String },
{ name: 'platform', type: String },
{ name: 'crosswalk', type: Boolean, default: false },
Expand Down
2 changes: 1 addition & 1 deletion lib/tasks/create-project.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ module.exports = Task.extend({
let projectName = camelize(this.project.name());

let create = new CreateCordova({
id: this.cordovaid || createProjectId(projectName),
id: this.cordovaId || createProjectId(projectName),
name: this.name || projectName,
templatePath: this.templatePath,
project: this.project,
Expand Down
32 changes: 25 additions & 7 deletions node-tests/unit/tasks/create-project-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe('Create Project', function() {
let createTask;
let tasks;

function initTask(mockInitDirs = true) {
function initTask(options = {}) {
tasks = [];

td.replace('../../../lib/utils/require-framework', function() {
Expand All @@ -34,8 +34,8 @@ describe('Create Project', function() {
createTask = new CreateProject({
project: mockProject.project,
ui: mockProject.ui,
cordovaId: 'io.corber.app',
name: 'io.corber.app'
cordovaId: options.cordovaId,
name: options.name
});

td.replace(CreateCordova.prototype, 'run', function() {
Expand All @@ -53,6 +53,7 @@ describe('Create Project', function() {
return Promise.resolve();
});

const mockInitDirs = 'mockInitDirs' in options ? options.mockInitDirs : true;
if (mockInitDirs) {
td.replace(createTask, 'initDirs', function() {
tasks.push('create-dirs');
Expand Down Expand Up @@ -98,7 +99,24 @@ describe('Create Project', function() {
return createTask.run().then(function() {
td.verify(new CreateCordova({
id: 'io.corber.corberMock',
name: 'io.corber.app',
name: 'corberMock',
templatePath: 'passedTemplatePath',
project: isAnything(),
ui: isAnything()
}));
});
});

it('inits CreateCordova with id, name & templatePath when a custom id and name are provided', function() {
let taskPath = '../../../lib/targets/cordova/tasks/create-project';
CreateCordova = td.replace(taskPath);
initTask({ cordovaId: 'io.corber.app', name: 'anAppName' });
createTask.templatePath = 'passedTemplatePath';

return createTask.run().then(function() {
td.verify(new CreateCordova({
id: 'io.corber.app',
name: 'anAppName',
templatePath: 'passedTemplatePath',
project: isAnything(),
ui: isAnything()
Expand All @@ -111,7 +129,7 @@ describe('Create Project', function() {
return ['custom'];
});

initTask(false);
initTask({ mockInitDirs: false });
let warnDouble = td.replace(createTask, 'warnCustomFramework');

return createTask.run().then(function() {
Expand Down Expand Up @@ -147,7 +165,7 @@ describe('Create Project', function() {
return Promise.resolve();
});

initTask(false);
initTask({ mockInitDirs: false });
return createTask.run().then(function() {
expect(mkDirPaths).to.include(emberCdvPath);
expect(mkDirPaths).to.include(emberCdvConfigPath);
Expand All @@ -163,7 +181,7 @@ describe('Create Project', function() {
return Promise.resolve();
});

initTask(false);
initTask({ mockInitDirs: false });

return createTask.run().then(function() {
let emberPath = path.join(
Expand Down

0 comments on commit f876db2

Please sign in to comment.