lib/generate.js
function(folder, dest) {
		try {
			fs.mkdirSync(dest, '0755');
		} catch (e) {}
		var files = fs.readdirSync(folder);
		var indexFile = templatesManager.getFolderIndex(files);
		logger.debug('Index file for "%s": "%s"', folder, indexFile);
		files.forEach(function(file) {
			if (config.exclude.indexOf(file) === -1) {
				var curPath = path.join(folder, file);
				if (fs.statSync(curPath).isDirectory()) {
					walk(curPath, path.join(dest, file));
				} else {
					if (['.md', '.markdown'].indexOf(path.extname(file).toLowerCase()) !== -1) {
						var isIndex = (file === indexFile);
						filesToRender[curPath] = {
							filename: file,
							path: curPath,
							versions: templatesManager.getVersions(curPath, 'template', isIndex),
							isIndex: isIndex
						};
					} else if (config.media.indexOf(path.extname(file).toLowerCase().substr(1)) !== -1) {
						logger.log('Copy "%s" to "%s"', curPath, path.join(dest, path.basename(curPath)));
						fs.copy(curPath, path.join(dest, path.basename(curPath)), {replace: true}, function(err) {
							if (err) {
								logger.error('Problem while copying media file "%s" to "%s": "%s"', curPath, path.join(dest, path.basename(curPath)), err);
							}
						});
					}
				}
			} else {
				logger.debug('Excluded:', file);
			}
		});
	}
function(folder, dest) {
		try {
			fs.mkdirSync(dest, '0755');
		} catch (e) {}
		var files = fs.readdirSync(folder);
		var indexFile = templatesManager.getFolderIndex(files);
		logger.debug('Index file for "%s": "%s"', folder, indexFile);
		files.forEach(function(file) {
			if (config.exclude.indexOf(file) === -1) {
				var curPath = path.join(folder, file);
				if (fs.statSync(curPath).isDirectory()) {
					walk(curPath, path.join(dest, file));
				} else {
					if (['.md', '.markdown'].indexOf(path.extname(file).toLowerCase()) !== -1) {
						var isIndex = (file === indexFile);
						filesToRender[curPath] = {
							filename: file,
							path: curPath,
							versions: templatesManager.getVersions(curPath, 'template', isIndex),
							isIndex: isIndex
						};
					} else if (config.media.indexOf(path.extname(file).toLowerCase().substr(1)) !== -1) {
						logger.log('Copy "%s" to "%s"', curPath, path.join(dest, path.basename(curPath)));
						fs.copy(curPath, path.join(dest, path.basename(curPath)), {replace: true}, function(err) {
							if (err) {
								logger.error('Problem while copying media file "%s" to "%s": "%s"', curPath, path.join(dest, path.basename(curPath)), err);
							}
						});
					}
				}
			} else {
				logger.debug('Excluded:', file);
			}
		});
	}
function ( folder , dest ) { try { fs . mkdirSync ( dest , '0755' ) ; } catch ( e ) { } var files = fs . readdirSync ( folder ) ; var indexFile = templatesManager . getFolderIndex ( files ) ; logger . debug ( 'Index file for "%s": "%s"' , folder , indexFile ) ; files . forEach ( function ( file ) { if ( config . exclude . indexOf ( file ) === - 1 ) { var curPath = path . join ( folder , file ) ; if ( fs . statSync ( curPath ) . isDirectory ( ) ) { walk ( curPath , path . join ( dest , file ) ) ; } else { if ( [ '.md' , '.markdown' ] . indexOf ( path . extname ( file ) . toLowerCase ( ) ) !== - 1 ) { var isIndex = ( file === indexFile ) ; filesToRender [ curPath ] = { filename : file , path : curPath , versions : templatesManager . getVersions ( curPath , 'template' , isIndex ) , isIndex : isIndex } ; } else if ( config . media . indexOf ( path . extname ( file ) . toLowerCase ( ) . substr ( 1 ) ) !== - 1 ) { logger . log ( 'Copy "%s" to "%s"' , curPath , path . join ( dest , path . basename ( curPath ) ) ) ; fs . copy ( curPath , path . join ( dest , path . basename ( curPath ) ) , { replace : true } , function ( err ) { if ( err ) { logger . error ( 'Problem while copying media file "%s" to "%s": "%s"' , curPath , path . join ( dest , path . basename ( curPath ) ) , err ) ; } } ) ; } } } else { logger . debug ( 'Excluded:' , file ) ; } } ) ; }
filename => filename, path, versions Function to discover Markdown files and copy media files
filename = > filename path versions Function to discover Markdown files and copy media files