function extensionCommand(shell, args, data, evaluationId) {
  var deferred = shell.runtime.q.defer();

  var name = args.name;
  var moduleName = 'ijs.ext.' + name;
  var modulePath = args.path || moduleName;

  installer.install(modulePath, shell.config.userPath, /* quiet */ true, function(error) {
    if (error) {
      deferred.reject(shell.createError('Unable to install extension module "%s"', moduleName));
    }
    else {
      var extensionPath = path.join(shell.config.userPath, 'node_modules', moduleName);
      var extension = require(extensionPath);

      try {
        extension.initialize(shell, function(error, result) {
          if (error) {
            deferred.reject(shell.createError('Error initializing extension'));
          }
          else {
            shell.loadedExtensions[name] = true;
            deferred.resolve(result);
          }
        });
      }
      catch(e) {
        deferred.reject(shell.createError('Error initializing extension'));
      }
    }
  })

  return deferred.promise;
}
function extensionCommand(shell, args, data, evaluationId) {
  var deferred = shell.runtime.q.defer();

  var name = args.name;
  var moduleName = 'ijs.ext.' + name;
  var modulePath = args.path || moduleName;

  installer.install(modulePath, shell.config.userPath,  true, function(error) {
    if (error) {
      deferred.reject(shell.createError('Unable to install extension module "%s"', moduleName));
    }
    else {
      var extensionPath = path.join(shell.config.userPath, 'node_modules', moduleName);
      var extension = require(extensionPath);

      try {
        extension.initialize(shell, function(error, result) {
          if (error) {
            deferred.reject(shell.createError('Error initializing extension'));
          }
          else {
            shell.loadedExtensions[name] = true;
            deferred.resolve(result);
          }
        });
      }
      catch(e) {
        deferred.reject(shell.createError('Error initializing extension'));
      }
    }
  })

  return deferred.promise;
}
function extensionCommand ( shell , args , data , evaluationId ) { var deferred = shell . runtime . q . defer ( ) ; var name = args . name ; var moduleName = 'ijs.ext.' + name ; var modulePath = args . path || moduleName ; installer . install ( modulePath , shell . config . userPath , /* quiet */ true , function ( error ) { if ( error ) { deferred . reject ( shell . createError ( 'Unable to install extension module "%s"' , moduleName ) ) ; } else { var extensionPath = path . join ( shell . config . userPath , 'node_modules' , moduleName ) ; var extension = require ( extensionPath ) ; try { extension . initialize ( shell , function ( error , result ) { if ( error ) { deferred . reject ( shell . createError ( 'Error initializing extension' ) ) ; } else { shell . loadedExtensions [ name ] = true ; deferred . resolve ( result ) ; } } ) ; } catch ( e ) { deferred . reject ( shell . createError ( 'Error initializing extension' ) ) ; } } } ) return deferred . promise ; }
Implements the %extension command, that can be used to install a specific named module as a shell extension, using npm.
Implements the %extension command that can be used to install a specific named module as a shell extension using npm .