Skip to content

Commit

Permalink
refactor(index): infer isCordova from cdv: command, deprecate EMBER_C…
Browse files Browse the repository at this point in the history
…LI_CORDOVA constant
  • Loading branch information
alexblom committed Mar 25, 2016
1 parent 3c29c1b commit bfe1815
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 15 deletions.
28 changes: 13 additions & 15 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,41 +1,39 @@
'use strict';

var rasterizeIcons = require('./broccoli-plugins/rasterize-icons/plugin');
var rasterizeSplashscreen = require('./broccoli-plugins/rasterize-splashscreen/plugin');

var path = require('path');
var fs = require('fs');
var commands = require('./lib/commands');
var inArray = require('./lib/utils/in-array');

//Livereload only
var defaults = require('lodash').defaults;
var chalk = require('chalk');
var mergeTrees = require('broccoli-merge-trees');
var Funnel = require('broccoli-funnel');
var path = require('path');
var fs = require('fs');

module.exports = {
name: 'ember-cordova',

_isTargetCordova: function () {
return true;
//return !process.env.EMBER_CLI_CORDOVA ||
// ['0', 'off', 'false', 'no'].indexOf(process.env.EMBER_CLI_CORDOVA.toLowerCase()) === -1;
var cordovaCommands = ['cdv:', 'cordova:'];
return inArray(cordovaCommands, process.argv);
},

config: function (env, config) {
var conf = {isCordovaBuild: this._isTargetCordova()};
if (conf.isCordovaBuild && env !== 'test') {
var conf = {};

if (this._isTargetCordova() && env !== 'test') {
if (config.locationType && config.locationType !== 'hash') {
throw new Error('ember-cli-cordova: You must specify the locationType as \'hash\' in your environment.js or rename it to defaultLocationType.');
}
conf.locationType = 'hash';
}
else if (!conf.locationType) {
} else if (!conf.locationType) {
conf.locationType = config.defaultLocationType || 'auto';
}
conf.cordova = defaults(config.cordova || {}, {
liveReload: {
enabled: false,
platform: 'ios'
}
});

return conf;
},

Expand Down
15 changes: 15 additions & 0 deletions lib/utils/in-array.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
'use strict';

module.exports = function inArray(keyArray, compArray) {
for (var i = 0; i < keyArray.length; i++) {
var key = keyArray[i];
for (var n = 0; n < compArray.length; n++) {
var item = compArray[n];
if (item.includes(key)) {
return true;
}
}
}
return false;
};

0 comments on commit bfe1815

Please sign in to comment.