Skip to content

Commit

Permalink
update new command to not take required args as options, closes #10
Browse files Browse the repository at this point in the history
  • Loading branch information
jakecraige committed May 27, 2014
1 parent 796d6dc commit 76ec5be
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 19 deletions.
1 change: 1 addition & 0 deletions bin/ember-cli-cordova.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ console.log('version:', emberCDVVersion(), '\n');
fs.exists(userCommandPath, function(exists){
if(exists) {
command = new (require('../lib/commands/' + userCommand))(options)

if(options._[1] === 'help' || options.h) {
command.displayHelp();
console.log();
Expand Down
40 changes: 21 additions & 19 deletions lib/commands/new.js
Original file line number Diff line number Diff line change
@@ -1,38 +1,40 @@
var async = require('async');
var path = require('path');
var chalk = require('chalk');
var Config = require('../utils/config');
var Command = require('../models/command');
var Project = require('../models/project');
var linkEnv = require('../tasks/link-environment');
var stringUtils = require('../utils/string');
var async = require('async');
var path = require('path');
var chalk = require('chalk');
var Config = require('../utils/config');
var Command = require('../models/command');
var Project = require('../models/project');
var linkEnv = require('../tasks/link-environment');
var stringUtils = require('../utils/string');

module.exports = Command.extend({
name: 'new',
description: 'Creates a cordova project with an ember-cli project inside with preinstalled dependencies and files for easy app development ',
commandSuffix: '--name|-n <app-name>(required) --id |-i <reverse.style.domain>(required) <options...>',
commandSuffix: '<app-name> <reverse.style.domain> <options...>',
optionsHelp: [
'--directory|-d (Default: project name)'
],
parseOptions: function() {
this.options.name = this.options.name || this.options.n;
this.options.id = this.options.id || this.options.i;
this.options.dirName = this.options.directory || this.options.d || this.options.name;
this.options.dirName = stringUtils.dasherize(this.options.dirName);
parseArgs: function() {
this.args.name = this.rawArgs[1];
this.args.id = this.rawArgs[2];
},
validateOptions: function() {
if(this.options.name && this.options.id) {
validateArgs: function() {
if(this.args.name && this.args.id) {
return true;
}
},
parseOptions: function() {
this.options.dirName = this.options.directory || this.options.d || this.args.name;
this.options.dirName = stringUtils.dasherize(this.options.dirName);
},
run: function() {
var projectPath = path.join(process.cwd(), this.options.dirName);
var configPath = path.join(projectPath, '.ember-cdv');

var config = new Config(configPath, {
projectPath: path.join(process.cwd(), this.options.dirName),
name: this.options.name,
id: this.options.id
name: this.args.name,
id: this.args.id
});

var tasks = [
Expand Down Expand Up @@ -61,7 +63,7 @@ module.exports = Command.extend({
config.flush(); // write config

// TODO: this is duplication of the path listed in
// commands/link-development. I'd like to remove it
// tasks/build. I'd like to remove it
linkEnv(Project.closest(projectPath), 'ember/tmp/output');

console.log('');
Expand Down

0 comments on commit 76ec5be

Please sign in to comment.