lib/css-purge.js
function getFilePaths(strPath = '', exts = ['.css']) {

		if (validUrl.isUri(strPath)){

			switch(exts[0]) {
				case '.css':
					tmpCSSPaths.push(strPath);
					break;
				case '.html':
				case '.htm':
					tmpHTMLPaths.push(strPath);
					break;
				case '.js':
					tmpJSPaths.push(strPath);
					break;
			}
		} else {

			try {
				// Query the entry
				fileStats = fs.lstatSync(strPath);

				// directory given
				if (fileStats.isDirectory()) {

					var dir = strPath;

					//traverse directory for .ext strPath
					try {

						fs.readdirSync(dir).forEach(filenameRead => {

							fileFound = false;

							for (m = 0, count = exts.length; m < count; ++m) {

								if (path.extname(filenameRead) == exts[m]) {
									fileFound = true;
								}
							}

							if (fileFound) {

								switch(exts[0]) {
									case '.css':
										tmpCSSPaths.push(dir + '/' + filenameRead);
										break;
									case '.html':
									case '.htm':
										tmpHTMLPaths.push(dir + '/' + filenameRead);
										break;
									case '.js':
										tmpJSPaths.push(dir + '/' + filenameRead);
										break;
								}

							} else if (path.extname(filenameRead) == '') {

								switch(exts[0]) {
									case '.css':
										getFilePaths(strPath+'/'+filenameRead, ['.css']);
										break;
									case '.html':
									case '.htm':
										getFilePaths(strPath+'/'+filenameRead, ['.html','.htm']);
										break;
									case '.js':
										getFilePaths(strPath+'/'+filenameRead, ['.js']);
										break;
								}

							}
						});



					} catch (e) {
						
						console.log(error("Directory read error: Something went wrong while reading the directory, check your [html] in " + configFileLocation + " and please try again."));
						console.log(e);
						process.exit(1);
					}

				} else if (fileStats.isFile()) { //filepath given

					if (exts.join(",").indexOf(strPath.substr(strPath.lastIndexOf('.') + 1)) != -1) {
						switch(exts[0]) {
							case '.css':
								tmpCSSPaths.push(strPath);
								break;
							case '.html':
							case '.htm':
								tmpHTMLPaths.push(strPath);
								break;
							case '.js':
								tmpJSPaths.push(strPath);
								break;
						}
					}
					
				}
			} catch (e) {
				
				console.log(error("CSS File read error: Something went wrong while reading the file(s), check your [html] in " + configFileLocation + " and please try again."));
				console.log(e);
				process.exit(1);
			}

		} //end of url check
	}
function getFilePaths(strPath = '', exts = ['.css']) {

		if (validUrl.isUri(strPath)){

			switch(exts[0]) {
				case '.css':
					tmpCSSPaths.push(strPath);
					break;
				case '.html':
				case '.htm':
					tmpHTMLPaths.push(strPath);
					break;
				case '.js':
					tmpJSPaths.push(strPath);
					break;
			}
		} else {

			try {
				// Query the entry
				fileStats = fs.lstatSync(strPath);

				// directory given
				if (fileStats.isDirectory()) {

					var dir = strPath;

					//traverse directory for .ext strPath
					try {

						fs.readdirSync(dir).forEach(filenameRead => {

							fileFound = false;

							for (m = 0, count = exts.length; m < count; ++m) {

								if (path.extname(filenameRead) == exts[m]) {
									fileFound = true;
								}
							}

							if (fileFound) {

								switch(exts[0]) {
									case '.css':
										tmpCSSPaths.push(dir + '/' + filenameRead);
										break;
									case '.html':
									case '.htm':
										tmpHTMLPaths.push(dir + '/' + filenameRead);
										break;
									case '.js':
										tmpJSPaths.push(dir + '/' + filenameRead);
										break;
								}

							} else if (path.extname(filenameRead) == '') {

								switch(exts[0]) {
									case '.css':
										getFilePaths(strPath+'/'+filenameRead, ['.css']);
										break;
									case '.html':
									case '.htm':
										getFilePaths(strPath+'/'+filenameRead, ['.html','.htm']);
										break;
									case '.js':
										getFilePaths(strPath+'/'+filenameRead, ['.js']);
										break;
								}

							}
						});



					} catch (e) {
						
						console.log(error("Directory read error: Something went wrong while reading the directory, check your [html] in " + configFileLocation + " and please try again."));
						console.log(e);
						process.exit(1);
					}

				} else if (fileStats.isFile()) { //filepath given

					if (exts.join(",").indexOf(strPath.substr(strPath.lastIndexOf('.') + 1)) != -1) {
						switch(exts[0]) {
							case '.css':
								tmpCSSPaths.push(strPath);
								break;
							case '.html':
							case '.htm':
								tmpHTMLPaths.push(strPath);
								break;
							case '.js':
								tmpJSPaths.push(strPath);
								break;
						}
					}
					
				}
			} catch (e) {
				
				console.log(error("CSS File read error: Something went wrong while reading the file(s), check your [html] in " + configFileLocation + " and please try again."));
				console.log(e);
				process.exit(1);
			}

		} //end of url check
	}
function getFilePaths ( strPath = '' , exts = [ '.css' ] ) { if ( validUrl . isUri ( strPath ) ) { switch ( exts [ 0 ] ) { case '.css' : tmpCSSPaths . push ( strPath ) ; break ; case '.html' : case '.htm' : tmpHTMLPaths . push ( strPath ) ; break ; case '.js' : tmpJSPaths . push ( strPath ) ; break ; } } else { try { // Query the entry fileStats = fs . lstatSync ( strPath ) ; // directory given if ( fileStats . isDirectory ( ) ) { var dir = strPath ; //traverse directory for .ext strPath try { fs . readdirSync ( dir ) . forEach ( filenameRead => { fileFound = false ; for ( m = 0 , count = exts . length ; m < count ; ++ m ) { if ( path . extname ( filenameRead ) == exts [ m ] ) { fileFound = true ; } } if ( fileFound ) { switch ( exts [ 0 ] ) { case '.css' : tmpCSSPaths . push ( dir + '/' + filenameRead ) ; break ; case '.html' : case '.htm' : tmpHTMLPaths . push ( dir + '/' + filenameRead ) ; break ; case '.js' : tmpJSPaths . push ( dir + '/' + filenameRead ) ; break ; } } else if ( path . extname ( filenameRead ) == '' ) { switch ( exts [ 0 ] ) { case '.css' : getFilePaths ( strPath + '/' + filenameRead , [ '.css' ] ) ; break ; case '.html' : case '.htm' : getFilePaths ( strPath + '/' + filenameRead , [ '.html' , '.htm' ] ) ; break ; case '.js' : getFilePaths ( strPath + '/' + filenameRead , [ '.js' ] ) ; break ; } } } ) ; } catch ( e ) { console . log ( error ( "Directory read error: Something went wrong while reading the directory, check your [html] in " + configFileLocation + " and please try again." ) ) ; console . log ( e ) ; process . exit ( 1 ) ; } } else if ( fileStats . isFile ( ) ) { //filepath given if ( exts . join ( "," ) . indexOf ( strPath . substr ( strPath . lastIndexOf ( '.' ) + 1 ) ) != - 1 ) { switch ( exts [ 0 ] ) { case '.css' : tmpCSSPaths . push ( strPath ) ; break ; case '.html' : case '.htm' : tmpHTMLPaths . push ( strPath ) ; break ; case '.js' : tmpJSPaths . push ( strPath ) ; break ; } } } } catch ( e ) { console . log ( error ( "CSS File read error: Something went wrong while reading the file(s), check your [html] in " + configFileLocation + " and please try again." ) ) ; console . log ( e ) ; process . exit ( 1 ) ; } } //end of url check }
end of processCSSFiles
end of processCSSFiles