Index: Gruntfile.js
===================================================================
--- Gruntfile.js	(revision 48933)
+++ Gruntfile.js	(working copy)
@@ -7,6 +7,7 @@
 module.exports = function(grunt) {
 	var path = require('path'),
 		fs = require( 'fs' ),
+		path = require( 'path' ),
 		spawn = require( 'child_process' ).spawnSync,
 		SOURCE_DIR = 'src/',
 		BUILD_DIR = 'build/',
@@ -1510,6 +1511,95 @@
 		} );
 	} );
 
+	grunt.registerTask( 'folders', 'Ensures every directory has an index.php file.', function() {
+		var folders = [
+			'js',
+			'wp-includes',
+			'wp-admin',
+			'wp-content',
+		],
+		blocked = [
+			'node_modules',
+			'src/js/_enqueues',
+			'src/wp-admin/network/',
+			'src/wp-admin/user/',
+			'src/wp-includes/blocks/',
+			'src/wp-includes/ID3',
+			'src/wp-includes/js',
+			'src/wp-includes/PHPMailer',
+			'src/wp-includes/pomo',
+			'src/wp-includes/Requests',
+			'src/wp-includes/SimplePie',
+			'src/wp-includes/sodium_compat',
+			'src/wp-includes/Text',
+		],
+		prefix = 'src/';
+
+		/**
+		 *
+		 * @param {string} dirPath Directory path to search against.
+		 * @param {array} arrayOfFiles Array of files in the directory.
+		 * @param {array} arrayOfFolders Array of directories in the directory.
+		 * @returns {array} Array of folders
+		 */
+		var getAllFolders = function( dirPath, arrayOfFiles, arrayOfFolders ) {
+			// Let's get all of the folders on this path.
+			var files = fs.readdirSync( dirPath );
+			arrayOfFiles = arrayOfFiles || [];
+			arrayOfFolders = arrayOfFolders || [];
+
+			// Let's loop through the folders, looking for more directories.
+			files.forEach(function(file) {
+				// Let's look for a directory.
+				if (fs.statSync(dirPath + "/" + file).isDirectory()) {
+					// Let's see if the path contains any of the `blocked` paths.
+					var dir = dirPath + "/" + file;
+					var block = false;
+					blocked.map(function(path) {
+						if( dir.includes(path) ) {
+							block = true;
+						}
+					});
+					// This is a legit path, let's add to our array of valid paths.
+					if ( ! block ) {
+						arrayOfFolders.push( dir );
+						arrayOfFolders = getAllFolders( dirPath + "/" + file, arrayOfFiles, arrayOfFolders );
+					}
+				} else {
+					// Keep digging for paths.
+					arrayOfFiles.push( path.join( __dirname, dirPath, "/", file ) );
+				}
+			});
+			return arrayOfFolders;
+
+		}
+
+		/**
+		 *
+		 * @param {string} dirPath Path to start a search for index.php files.
+		 * @returns {bool}
+		 */
+		var doesDirHaveIndex = function ( dirPath ) {
+			var index = '/index.php';
+			return fs.existsSync(dirPath + index);
+		}
+
+		// Loop through folders, looking for blank index.php files.
+		folders.forEach(function(path) {
+			var folder = getAllFolders( prefix + path );
+			folder.forEach(function(path) {
+				if( ! doesDirHaveIndex( path ) ) {
+					var newFile = path + '/index.php';
+					// Read a default file, and stream that into a new file.
+					var index = fs.readFileSync('src/wp-content/index.php');
+					// The `wx` flag ensures that it doesn't overwrite any existing files.
+					fs.writeFileSync( newFile, index, {flag: "wx"} );
+				}
+			})
+		});
+
+	} );
+
 	// Travis CI tasks.
 	grunt.registerTask('travis:js', 'Runs Javascript Travis CI tasks.', [ 'jshint:corejs', 'qunit:compiled' ]);
 	grunt.registerTask('travis:phpunit', 'Runs PHPUnit Travis CI tasks.', [ 'build', 'phpunit' ]);
