src/core/base/wnConsole.js
function (serverPath)
		{
			if (!_.isString(serverPath))
				return false;

			var _sourcePath = cwd+sourcePath,
				relativeSourcePath = path.relative(serverPath,_sourcePath)+'/',
				relativeServerPath = path.relative(cwd,serverPath);

			self.e.log("[*] Building new wnServer on `"+serverPath+"`");

			if (!fs.existsSync(serverPath))
				fs.mkdirSync(serverPath);

			self.e.log("[*] - Creating new `package.js` file.");
			var defaultPackage = fs.readFileSync(_sourcePath+'/default-package.json').toString('utf8');
			defaultPackage = (defaultPackage+'').replace(/\{moduleName\}/g, 'server-'+serverPath.substr(0,serverPath.length-1).split('/').pop().replace(/\s/g,'-'));
			fs.writeFileSync(serverPath+'/package.json',defaultPackage);

			self.e.log("[*] - Creating new `config.json` file.");
			fs.writeFileSync(serverPath+'/config.json',
				fs.readFileSync(_sourcePath+'/default-config.json')
			);

			self.e.log("[*] - Creating new `index.js` file.");
			var defaultIndex = fs.readFileSync(_sourcePath+'/default-index.js').toString('utf8');
			defaultIndex = defaultIndex.replace(/\{sourcePath\}/g,'./'+relativeSourcePath.replace(/\\/g,'/'));
			defaultIndex = defaultIndex.replace(/\{serverPath\}/g,'./'+relativeServerPath.replace(/\\/g,'/'));
			fs.writeFileSync(serverPath+'/index.js',defaultIndex);

			self.e.log('[*] New wnServer created.');

			return true;
		}
function (serverPath)
		{
			if (!_.isString(serverPath))
				return false;

			var _sourcePath = cwd+sourcePath,
				relativeSourcePath = path.relative(serverPath,_sourcePath)+'/',
				relativeServerPath = path.relative(cwd,serverPath);

			self.e.log("[*] Building new wnServer on `"+serverPath+"`");

			if (!fs.existsSync(serverPath))
				fs.mkdirSync(serverPath);

			self.e.log("[*] - Creating new `package.js` file.");
			var defaultPackage = fs.readFileSync(_sourcePath+'/default-package.json').toString('utf8');
			defaultPackage = (defaultPackage+'').replace(/\{moduleName\}/g, 'server-'+serverPath.substr(0,serverPath.length-1).split('/').pop().replace(/\s/g,'-'));
			fs.writeFileSync(serverPath+'/package.json',defaultPackage);

			self.e.log("[*] - Creating new `config.json` file.");
			fs.writeFileSync(serverPath+'/config.json',
				fs.readFileSync(_sourcePath+'/default-config.json')
			);

			self.e.log("[*] - Creating new `index.js` file.");
			var defaultIndex = fs.readFileSync(_sourcePath+'/default-index.js').toString('utf8');
			defaultIndex = defaultIndex.replace(/\{sourcePath\}/g,'./'+relativeSourcePath.replace(/\\/g,'/'));
			defaultIndex = defaultIndex.replace(/\{serverPath\}/g,'./'+relativeServerPath.replace(/\\/g,'/'));
			fs.writeFileSync(serverPath+'/index.js',defaultIndex);

			self.e.log('[*] New wnServer created.');

			return true;
		}
function ( serverPath ) { if ( ! _ . isString ( serverPath ) ) return false ; var _sourcePath = cwd + sourcePath , relativeSourcePath = path . relative ( serverPath , _sourcePath ) + '/' , relativeServerPath = path . relative ( cwd , serverPath ) ; self . e . log ( "[*] Building new wnServer on `" + serverPath + "`" ) ; if ( ! fs . existsSync ( serverPath ) ) fs . mkdirSync ( serverPath ) ; self . e . log ( "[*] - Creating new `package.js` file." ) ; var defaultPackage = fs . readFileSync ( _sourcePath + '/default-package.json' ) . toString ( 'utf8' ) ; defaultPackage = ( defaultPackage + '' ) . replace ( / \{moduleName\} / g , 'server-' + serverPath . substr ( 0 , serverPath . length - 1 ) . split ( '/' ) . pop ( ) . replace ( / \s / g , '-' ) ) ; fs . writeFileSync ( serverPath + '/package.json' , defaultPackage ) ; self . e . log ( "[*] - Creating new `config.json` file." ) ; fs . writeFileSync ( serverPath + '/config.json' , fs . readFileSync ( _sourcePath + '/default-config.json' ) ) ; self . e . log ( "[*] - Creating new `index.js` file." ) ; var defaultIndex = fs . readFileSync ( _sourcePath + '/default-index.js' ) . toString ( 'utf8' ) ; defaultIndex = defaultIndex . replace ( / \{sourcePath\} / g , './' + relativeSourcePath . replace ( / \\ / g , '/' ) ) ; defaultIndex = defaultIndex . replace ( / \{serverPath\} / g , './' + relativeServerPath . replace ( / \\ / g , '/' ) ) ; fs . writeFileSync ( serverPath + '/index.js' , defaultIndex ) ; self . e . log ( '[*] New wnServer created.' ) ; return true ; }
Build a new server structure on the given directory
@param string $serverPath directory of the new server
@return boolean successfully builded?
Build a new server structure on the given directory