var path = require('path');

function rename (dest, src) {
	var basename = path.basename(src, path.extname(src));

	if (basename === "index") {
		basename = "";
	}

	return path.join(dest, path.dirname(src), basename, 'index.html');
}

module.exports = function(grunt) {
	grunt.config('assemble', {
		'options' : {
			partials   : 'pages/partials/**/*.hbs',
			layoutdir  : 'pages/layout',
			helpers    : 'pages/helpers/**/*.js',
			marked     : { sanitize: false },
			lang       : require('../data/lang.js'),
			size       : require('../data/size.js')
		},
		'moment' : {
			options : {
				docs : require('../.temp/docs/moment.json')
			},
			files: [{
				expand : true,
				rename : rename,
				dest   : 'build',
				cwd    : 'pages/moment',
				src    : '**/*.{hbs,md}'
			}]
		},
		'moment-timezone' : {
			options : {
				docs : require('../.temp/docs/moment-timezone.json')
			},
			files: [{
				expand : true,
				rename : rename,
				dest   : 'build/timezone',
				cwd    : 'pages/moment-timezone',
				src    : '**/*.hbs'
			}]
		}
	});

	grunt.registerTask('html', [
		'docs:moment',
		'docs:moment-timezone',
		'assemble:moment',
		'assemble:moment-timezone'
	]);

	grunt.config('watch.html-moment', {
		files: [
			'.temp/docs/moment.json',
			'pages/**/*.{hbs,json,md}'
		],
		tasks: ['assemble:moment']
	});

	grunt.config('watch.html-moment-timezone', {
		files: [
			'.temp/docs/moment-timezone.json',
			'pages/**/*.{hbs,json,md}'
		],
		tasks: ['assemble:moment-timezone']
	});
};

@@ -1270,32 +1270,35 @@
 */*.%7Bhbs,json,md
+,js
 %7D'%0A%09%09%5D,%0A%09%09tasks:
@@ -1446,16 +1446,19 @@
 ,json,md
+,js
 %7D'%0A%09%09%5D,%0A

Include js helpers in grunt watch