lib/utils.js
function updateFiles(files, func, bpath, eh) {
	try {
		if (Array.isArray(files) && typeof func === 'function') {
			for (var i = 0; i < files.length; i++) {
				var p = path.join(bpath, files[i]), au = '';
				var content = rbot.file.read(p, {
					encoding : rbot.file.defaultEncoding
				});
				var ec = func(content, p);
				if (content !== ec) {
					rbot.file.write(p, ec);
					return au;
				}
			}
		}
	} catch (e) {
		if (typeof eh === 'function') {
			return eh('Unable to update "' + (Array.isArray(files) ? files.join(',') : '') + '" using: ' + func, e);
		}
		throw e;
	}
}
function updateFiles(files, func, bpath, eh) {
	try {
		if (Array.isArray(files) && typeof func === 'function') {
			for (var i = 0; i < files.length; i++) {
				var p = path.join(bpath, files[i]), au = '';
				var content = rbot.file.read(p, {
					encoding : rbot.file.defaultEncoding
				});
				var ec = func(content, p);
				if (content !== ec) {
					rbot.file.write(p, ec);
					return au;
				}
			}
		}
	} catch (e) {
		if (typeof eh === 'function') {
			return eh('Unable to update "' + (Array.isArray(files) ? files.join(',') : '') + '" using: ' + func, e);
		}
		throw e;
	}
}
function updateFiles ( files , func , bpath , eh ) { try { if ( Array . isArray ( files ) && typeof func === 'function' ) { for ( var i = 0 ; i < files . length ; i ++ ) { var p = path . join ( bpath , files [ i ] ) , au = '' ; var content = rbot . file . read ( p , { encoding : rbot . file . defaultEncoding } ) ; var ec = func ( content , p ) ; if ( content !== ec ) { rbot . file . write ( p , ec ) ; return au ; } } } } catch ( e ) { if ( typeof eh === 'function' ) { return eh ( 'Unable to update "' + ( Array . isArray ( files ) ? files . join ( ',' ) : '' ) + '" using: ' + func , e ) ; } throw e ; } }
Updates file contents using a specified function

@param files
the {Array} of files to read/write
@param func
the function to call for the read/write operation
@param bpath
the base path to that will be used to prefix each file used in the
update process
@param eh
an optional function that will be called when the update fails
@returns {String} the replaced URL (undefined if nothing was replaced)
Updates file contents using a specified function