Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Updated for Node.js > 0.6

  • Loading branch information...
commit de4e12bce87c4b85d208afbcb0a9d746b2a282c7 1 parent e723a8a
@xcambar authored
Showing with 57 additions and 51 deletions.
  1. +57 −51 node_modules/n-ext/index.js
View
108 node_modules/n-ext/index.js
@@ -1,3 +1,9 @@
+function _addPath (name) {
+ var _tmpPath = process.env.PATH.split(':');
+ _tmpPath.unshift(name);
+ process.env.PATH = _tmpPath.join(':');
+}
+
/**
* Provides the loading of Ext Core
* We do NOT load ext-core.js nor ext-core-debug.js nor ext-core-dev.js
@@ -5,12 +11,12 @@
* and we want the most minimalistic portion of Ext possible
*/
var nExtLoader = function() {
- //The cached library after the first bootstrap
- var _ExtCache = null;
-
- var _defaultExtGetter;
- var _defaultExtSetter;
-
+ //The cached library after the first bootstrap
+ var _ExtCache = null;
+
+ var _defaultExtGetter;
+ var _defaultExtSetter;
+
/**
* In which path are the Ext-core-srv sources located ?
* @type string
@@ -33,47 +39,48 @@ var nExtLoader = function() {
* Defines a debug/development environment
*/
var _debug = false;
-
+
/**
* Loads the required files
- * @param sandbox Whether Ext should be defined application-wide or returned by the function to be used locally
+ * @param sandbox Whether Ext should be defined application-wide or returned by the function to be used locally
*/
this.bootstrapCore = function() {
- if (_ExtCache === null) {
- require(_prefix + 'Ext.js');
- require(_prefix + 'version/Version.js');
- require(_prefix + 'lang/Array.js');
- require(_prefix + 'lang/Date.js');
- require(_prefix + 'lang/Function.js');
- require(_prefix + 'lang/Number.js');
- require(_prefix + 'lang/Object.js');
- require(_prefix + 'lang/String.js');
- require(_prefix + 'class/Base.js');
- require(_prefix + 'class/Class.js');
- require(_prefix + 'class/ClassManager.js');
- require(_prefix + 'lang/Error.js');
- require(_prefix + 'class/Loader.js');
- //Ext.Loader may be used from here, but we still use Node.js require method to end loading the core
- require(_prefix + 'util/Format.js');
- require(_prefix + 'util/DelayedTask.js');
- require(_prefix + 'util/Event.js');
- // The latest require are not strictly mandatory, but really useful
- require(_prefix + 'util/TaskManager.js');
- require(_prefix + 'misc/JSON.js');
- require(_prefix + 'Ext-more-srv.js');
-
- Ext.Loader.config.enabled = true;
- Ext.Loader.setPath('Ext', _libPath);
- require.paths.unshift(_libPath + '/../') //Defines the path where Ext is located as a default namespace location
- global.__defineGetter__('window', function() {
- return {};
- });
- Ext.require('Ext.ModelManager');
- Ext.require('Ext.data.Store');
- _ExtCache = Ext.apply({}, Ext);
- } else {
- global.Ext = _ExtCache.apply({}, _ExtCache);
- }
+ if (_ExtCache === null) {
+ require(_prefix + 'Ext.js');
+ require(_prefix + 'version/Version.js');
+ require(_prefix + 'lang/Array.js');
+ require(_prefix + 'lang/Date.js');
+ require(_prefix + 'lang/Function.js');
+ require(_prefix + 'lang/Number.js');
+ require(_prefix + 'lang/Object.js');
+ require(_prefix + 'lang/String.js');
+ require(_prefix + 'class/Base.js');
+ require(_prefix + 'class/Class.js');
+ require(_prefix + 'class/ClassManager.js');
+ require(_prefix + 'lang/Error.js');
+ require(_prefix + 'class/Loader.js');
+ //Ext.Loader may be used from here, but we still use Node.js require method to end loading the core
+ require(_prefix + 'util/Format.js');
+ require(_prefix + 'util/DelayedTask.js');
+ require(_prefix + 'util/Event.js');
+ // The latest require are not strictly mandatory, but really useful
+ require(_prefix + 'util/TaskManager.js');
+ require(_prefix + 'misc/JSON.js');
+ require(_prefix + 'Ext-more-srv.js');
+
+ Ext.Loader.config.enabled = true;
+
+ Ext.Loader.setPath('Ext', _libPath);
+ _addPath(_libPath + '/../');
+ global.__defineGetter__('window', function() {
+ return {};
+ });
+ Ext.require('Ext.ModelManager');
+ Ext.require('Ext.data.Store');
+ _ExtCache = Ext.apply({}, Ext);
+ } else {
+ global.Ext = _ExtCache.apply({}, _ExtCache);
+ }
};
/**
@@ -81,22 +88,22 @@ var nExtLoader = function() {
*/
this.setExtPath = function(p) {
_libPath = p;
- }
+ };
/**
* Enables the autoloading of any namespace located in the libPath
*/
this.addLibPath = function(path) {
- _customLibPaths.push(path);
- require.paths.unshift(path);
- }
+ _customLibPaths.push(path);
+ _addPath(path);
+ };
/**
* Defines the debug/development environment
*/
this.setDebug = function(value) {
_debug = value;
- }
+ };
/**
* Unsets the wole Ext environment
@@ -104,11 +111,10 @@ var nExtLoader = function() {
this.unset = function() {
_ExtCache.Array.remove(require.paths, _libPath);
_ExtCache.Array.forEach(_customLibPaths, function(path) {
- console.log(path);
- _ExtCache.Array.remove(require.paths, path);
+ _ExtCache.Array.remove(require.paths, path);
});
delete(global.Ext);
- }
+ };
};
module.exports = new nExtLoader();
Please sign in to comment.
Something went wrong with that request. Please try again.