File tree Expand file tree Collapse file tree 3 files changed +22
-2
lines changed
node-tests/unit/tasks/validate Expand file tree Collapse file tree 3 files changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -76,7 +76,8 @@ module.exports = Command.extend({
7676
7777 validations . push (
7878 new ValidateLocationType ( {
79- config : projectConfig
79+ config : projectConfig ,
80+ force : options . force
8081 } ) . run ( )
8182 ) ;
8283 }
Original file line number Diff line number Diff line change 11var Task = require ( '../-task' ) ;
22var Promise = require ( 'rsvp' ) . Promise ;
33var chalk = require ( 'chalk' ) ;
4+ var logger = require ( '../../utils/logger' ) ;
45
56var MUST_SPECIFY_HASH =
67 chalk . red ( '* config/environment.js: Cordova applications require:' ) +
78 chalk . grey ( '\n`ENV.locationType = \'hash\'; \n' ) ;
89
910module . exports = Task . extend ( {
1011 config : undefined ,
12+ force : false ,
1113
1214 run : function ( ) {
1315 var config = this . config ;
1416 var locationType = config . locationType ;
1517 var isHashLocation = locationType === 'hash' ;
1618
17- if ( ! isHashLocation ) {
19+ if ( ! isHashLocation && this . force === false ) {
1820 return Promise . reject ( MUST_SPECIFY_HASH ) ;
21+ } else {
22+ var msg = MUST_SPECIFY_HASH ;
23+ msg += 'You have passed the --force flag, so continuing' ;
24+ logger . warn ( msg ) ;
1925 }
2026
2127 return Promise . resolve ( ) ;
Original file line number Diff line number Diff line change @@ -4,6 +4,8 @@ var td = require('testdouble');
44var expect = require ( '../../../helpers/expect' ) ;
55var mockProject = require ( '../../../fixtures/ember-cordova-mock/project' ) ;
66var ValidateLocType = require ( '../../../../lib/tasks/validate/location-type' ) ;
7+ var logger = require ( '../../../../lib/utils/logger' ) ;
8+ var contains = td . matchers . contains ;
79
810describe ( 'Validate Location Type' , function ( ) {
911 var validateLoc ;
@@ -32,4 +34,15 @@ describe('Validate Location Type', function() {
3234 validateLoc . config = { locationType : 'hash' } ;
3335 return expect ( validateLoc . run ( ) ) . to . be . fulfilled ;
3436 } ) ;
37+
38+ it ( 'when force is true, it warns vs rejects' , function ( ) {
39+ validateLoc . config = { locationType : 'auto' } ;
40+ validateLoc . force = true ;
41+
42+ var warnDouble = td . replace ( logger , 'warn' ) ;
43+
44+ return validateLoc . run ( ) . then ( function ( ) {
45+ td . verify ( warnDouble ( contains ( 'You have passed the --force flag' ) ) ) ;
46+ } )
47+ } ) ;
3548} ) ;
You can’t perform that action at this time.
0 commit comments