@@ -410,20 +410,23 @@ define(function (require, exports, module) {
410410 }
411411
412412 /**
413- * Disables the installed extension with the given id.
413+ * @private
414414 *
415- * @param {string } id The id of the extension to disable.
416- * @return {$.Promise } A promise that's resolved when the extenion is disabled or
417- * rejected with an error that prevented the disabling.
415+ * Disables or enables the installed extensions.
416+ *
417+ * @param {string } id The id of the extension to disable or enable.
418+ * @param {boolean } enable A boolean indicating whether to enable or disable.
419+ * @return {$.Promise } A promise that's resolved when the extension action is
420+ * completed or rejected with an error that prevents the action from completion.
418421 */
419- function disable ( id ) {
422+ function _enableOrDisable ( id , enable ) {
420423 var result = new $ . Deferred ( ) ,
421424 extension = extensions [ id ] ;
422425 if ( extension && extension . installInfo ) {
423- Package . disable ( extension . installInfo . path )
426+ Package [ ( enable ? "enable" : " disable" ) ] ( extension . installInfo . path )
424427 . done ( function ( ) {
425- extension . installInfo . status = DISABLED ;
426- extension . installInfo . metadata . disabled = true ;
428+ extension . installInfo . status = enable ? ENABLED : DISABLED ;
429+ extension . installInfo . metadata . disabled = ! enable ;
427430 result . resolve ( ) ;
428431 exports . trigger ( "statusChange" , id ) ;
429432 } )
@@ -436,6 +439,17 @@ define(function (require, exports, module) {
436439 return result . promise ( ) ;
437440 }
438441
442+ /**
443+ * Disables the installed extension with the given id.
444+ *
445+ * @param {string } id The id of the extension to disable.
446+ * @return {$.Promise } A promise that's resolved when the extenion is disabled or
447+ * rejected with an error that prevented the disabling.
448+ */
449+ function disable ( id ) {
450+ return _enableOrDisable ( id , false ) ;
451+ }
452+
439453 /**
440454 * Enables the installed extension with the given id.
441455 *
@@ -444,23 +458,7 @@ define(function (require, exports, module) {
444458 * rejected with an error that prevented the enabling.
445459 */
446460 function enable ( id ) {
447- var result = new $ . Deferred ( ) ,
448- extension = extensions [ id ] ;
449- if ( extension && extension . installInfo ) {
450- Package . enable ( extension . installInfo . path )
451- . done ( function ( ) {
452- extension . installInfo . status = ENABLED ;
453- extension . installInfo . metadata . disabled = false ;
454- result . resolve ( ) ;
455- exports . trigger ( "statusChange" , id ) ;
456- } )
457- . fail ( function ( err ) {
458- result . reject ( err ) ;
459- } ) ;
460- } else {
461- result . reject ( StringUtils . format ( Strings . EXTENSION_NOT_INSTALLED , id ) ) ;
462- }
463- return result . promise ( ) ;
461+ return _enableOrDisable ( id , true ) ;
464462 }
465463
466464 /**
0 commit comments