src/core/base/wnModule.js
function ()
		{
			var nmPath = this.modulePath + 'node_modules/';
			var pkgJson;
			var pkgName;
			var pkgInfo;
			var packageList = {};
			var validScript = /[\w|\W]+\.[js|coffee]+$/;
			if (fs.existsSync(nmPath))
			{
				this.e.log&&this.e.log('Importing packages...','system');
				var packages = fs.readdirSync(nmPath);
				for (p in packages)
				{
					try {
						if (packages[p].indexOf('wns')!==-1 &&
							(packages[p].indexOf('pkg') !== -1 || packages[p].indexOf('package') !== -1))
						{
							pkgName = packages[p];
							pkgDir = nmPath + pkgName;
							pkgJson = pkgDir + '/package.json';
							if (fs.existsSync(pkgJson))
							{
								pkgInfo = JSON.parse(fs.readFileSync(pkgJson));
								pkgInfo.require = pkgInfo.require||{};
								Object.defineProperty(pkgInfo,'classes',{ value: {}, enumerable: false })
								var files = fs.readdirSync(pkgDir);
								for (f in files)
								{
									var fileName = files[f].split('/').pop();
									if (validScript.test(fileName))
									{
										var className = fileName.split('.');
										className.splice(-1);
										pkgInfo.classes[className] = pkgDir+'/'+fileName;
									}
								}
								packageList[pkgInfo.name]=pkgInfo;
							}
						}
					} catch (e)
					{
						console.error('Error on loading package `'+pkgName+"`.")
						throw e;
					}
				}
			}

			this.removeInvalidPackages(packageList);
			this.loadPackages(packageList);
		}
function ()
		{
			var nmPath = this.modulePath + 'node_modules/';
			var pkgJson;
			var pkgName;
			var pkgInfo;
			var packageList = {};
			var validScript = /[\w|\W]+\.[js|coffee]+$/;
			if (fs.existsSync(nmPath))
			{
				this.e.log&&this.e.log('Importing packages...','system');
				var packages = fs.readdirSync(nmPath);
				for (p in packages)
				{
					try {
						if (packages[p].indexOf('wns')!==-1 &&
							(packages[p].indexOf('pkg') !== -1 || packages[p].indexOf('package') !== -1))
						{
							pkgName = packages[p];
							pkgDir = nmPath + pkgName;
							pkgJson = pkgDir + '/package.json';
							if (fs.existsSync(pkgJson))
							{
								pkgInfo = JSON.parse(fs.readFileSync(pkgJson));
								pkgInfo.require = pkgInfo.require||{};
								Object.defineProperty(pkgInfo,'classes',{ value: {}, enumerable: false })
								var files = fs.readdirSync(pkgDir);
								for (f in files)
								{
									var fileName = files[f].split('/').pop();
									if (validScript.test(fileName))
									{
										var className = fileName.split('.');
										className.splice(-1);
										pkgInfo.classes[className] = pkgDir+'/'+fileName;
									}
								}
								packageList[pkgInfo.name]=pkgInfo;
							}
						}
					} catch (e)
					{
						console.error('Error on loading package `'+pkgName+"`.")
						throw e;
					}
				}
			}

			this.removeInvalidPackages(packageList);
			this.loadPackages(packageList);
		}
function ( ) { var nmPath = this . modulePath + 'node_modules/' ; var pkgJson ; var pkgName ; var pkgInfo ; var packageList = { } ; var validScript = / [\w|\W]+\.[js|coffee]+$ / ; if ( fs . existsSync ( nmPath ) ) { this . e . log && this . e . log ( 'Importing packages...' , 'system' ) ; var packages = fs . readdirSync ( nmPath ) ; for ( p in packages ) { try { if ( packages [ p ] . indexOf ( 'wns' ) !== - 1 && ( packages [ p ] . indexOf ( 'pkg' ) !== - 1 || packages [ p ] . indexOf ( 'package' ) !== - 1 ) ) { pkgName = packages [ p ] ; pkgDir = nmPath + pkgName ; pkgJson = pkgDir + '/package.json' ; if ( fs . existsSync ( pkgJson ) ) { pkgInfo = JSON . parse ( fs . readFileSync ( pkgJson ) ) ; pkgInfo . require = pkgInfo . require || { } ; Object . defineProperty ( pkgInfo , 'classes' , { value : { } , enumerable : false } ) var files = fs . readdirSync ( pkgDir ) ; for ( f in files ) { var fileName = files [ f ] . split ( '/' ) . pop ( ) ; if ( validScript . test ( fileName ) ) { var className = fileName . split ( '.' ) ; className . splice ( - 1 ) ; pkgInfo . classes [ className ] = pkgDir + '/' + fileName ; } } packageList [ pkgInfo . name ] = pkgInfo ; } } } catch ( e ) { console . error ( 'Error on loading package `' + pkgName + "`." ) throw e ; } } } this . removeInvalidPackages ( packageList ) ; this . loadPackages ( packageList ) ; }
Import package classes from node_modules directory
Import package classes from node_modules directory