lib/mage/Mage.js
function Mage(mageRootModule) {
	EventEmitter.call(this);

	this.workerId = require('./worker').getId();
	this.MageError = require('./MageError');
	this.task = null;

	this._runState = 'init';
	this._modulesList = [];
	this._modulePaths = [
		applicationModulesPath
	];
	this._setupQueue = [];
	this._teardownQueue = [];

	// Set up the core object that holds some crucial Mage libraries

	this.core = { modules: {} };

	// Register the Mage version

	var magePath = path.join(path.dirname(__dirname), '..');

	var magePackagePath = path.join(magePath, 'package.json');
	var rootPackagePath = path.join(rootPath, 'package.json');

	var magePackage = require(magePackagePath);
	var rootPackage;

	try {
		rootPackage = require(rootPackagePath);
	} catch (error) {
		console.warn('Could not load your project\'s "package.json"', error);
	}

	var appName = rootPackage && rootPackage.name || path.basename(rootPath);
	var appVersion = rootPackage && rootPackage.version;

	this.version = magePackage.version;

	this.magePackage = {
		name: 'mage',
		version: magePackage.version,
		path: magePath,
		package: magePackage
	};

	this.rootPackage = {
		name: appName,
		version: appVersion,
		path: rootPath,
		package: rootPackage
	};

	// test the supported node version of mage itself as soon as possible

	testEngineVersion(this.magePackage.package, magePackagePath, this);
	testEngineVersion(this.rootPackage.package, rootPackagePath, this);

	require('codependency').register(mageRootModule);
}
function Mage(mageRootModule) {
	EventEmitter.call(this);

	this.workerId = require('./worker').getId();
	this.MageError = require('./MageError');
	this.task = null;

	this._runState = 'init';
	this._modulesList = [];
	this._modulePaths = [
		applicationModulesPath
	];
	this._setupQueue = [];
	this._teardownQueue = [];

	// Set up the core object that holds some crucial Mage libraries

	this.core = { modules: {} };

	// Register the Mage version

	var magePath = path.join(path.dirname(__dirname), '..');

	var magePackagePath = path.join(magePath, 'package.json');
	var rootPackagePath = path.join(rootPath, 'package.json');

	var magePackage = require(magePackagePath);
	var rootPackage;

	try {
		rootPackage = require(rootPackagePath);
	} catch (error) {
		console.warn('Could not load your project\'s "package.json"', error);
	}

	var appName = rootPackage && rootPackage.name || path.basename(rootPath);
	var appVersion = rootPackage && rootPackage.version;

	this.version = magePackage.version;

	this.magePackage = {
		name: 'mage',
		version: magePackage.version,
		path: magePath,
		package: magePackage
	};

	this.rootPackage = {
		name: appName,
		version: appVersion,
		path: rootPath,
		package: rootPackage
	};

	// test the supported node version of mage itself as soon as possible

	testEngineVersion(this.magePackage.package, magePackagePath, this);
	testEngineVersion(this.rootPackage.package, rootPackagePath, this);

	require('codependency').register(mageRootModule);
}
function Mage ( mageRootModule ) { EventEmitter . call ( this ) ; this . workerId = require ( './worker' ) . getId ( ) ; this . MageError = require ( './MageError' ) ; this . task = null ; this . _runState = 'init' ; this . _modulesList = [ ] ; this . _modulePaths = [ applicationModulesPath ] ; this . _setupQueue = [ ] ; this . _teardownQueue = [ ] ; // Set up the core object that holds some crucial Mage libraries this . core = { modules : { } } ; // Register the Mage version var magePath = path . join ( path . dirname ( __dirname ) , '..' ) ; var magePackagePath = path . join ( magePath , 'package.json' ) ; var rootPackagePath = path . join ( rootPath , 'package.json' ) ; var magePackage = require ( magePackagePath ) ; var rootPackage ; try { rootPackage = require ( rootPackagePath ) ; } catch ( error ) { console . warn ( 'Could not load your project\'s "package.json"' , error ) ; } var appName = rootPackage && rootPackage . name || path . basename ( rootPath ) ; var appVersion = rootPackage && rootPackage . version ; this . version = magePackage . version ; this . magePackage = { name : 'mage' , version : magePackage . version , path : magePath , package : magePackage } ; this . rootPackage = { name : appName , version : appVersion , path : rootPath , package : rootPackage } ; // test the supported node version of mage itself as soon as possible testEngineVersion ( this . magePackage . package , magePackagePath , this ) ; testEngineVersion ( this . rootPackage . package , rootPackagePath , this ) ; require ( 'codependency' ) . register ( mageRootModule ) ; }
The mage class.

@constructor
@extends EventEmitter
The mage class .