浏览代码

Replaced "white list" with "allowed".

Kamil Piechaczek 5 年之前
父节点
当前提交
247eb6c804
共有 2 个文件被更改,包括 11 次插入11 次删除
  1. 2 2
      scripts/docs/build-docs.js
  2. 9 9
      scripts/docs/snippetadapter.js

+ 2 - 2
scripts/docs/build-docs.js

@@ -17,7 +17,7 @@ const skipValidation = process.argv.includes( '--skip-validation' );
 const production = process.argv.includes( '--production' );
 const watch = process.argv.includes( '--watch' );
 const verbose = process.argv.includes( '--verbose' );
-const whitelistedSnippets = process.argv.find( item => item.startsWith( '--snippets=' ) );
+const allowedSnippets = process.argv.find( item => item.startsWith( '--snippets=' ) );
 
 buildDocs();
 
@@ -59,7 +59,7 @@ function runUmberto( options ) {
 		skipValidation: options.skipValidation,
 		snippetOptions: {
 			production: options.production,
-			whitelistedSnippets: whitelistedSnippets ? whitelistedSnippets.replace( '--snippets=', '' ).split( ',' ) : []
+			allowedSnippets: allowedSnippets ? allowedSnippets.replace( '--snippets=', '' ).split( ',' ) : []
 		},
 		skipApi: options.skipApi,
 		verbose: options.verbose,

+ 9 - 9
scripts/docs/snippetadapter.js

@@ -22,7 +22,7 @@ const MULTI_LANGUAGE = 'multi-language';
  * @param {Set.<Snippet>} snippets Snippet collection extracted from documentation files.
  * @param {Object} options
  * @param {Boolean} options.production Whether to build snippets in production mode.
- * @param {Array.<String>|undefined} options.whitelistedSnippets An array that contains glob patterns.
+ * @param {Array.<String>|undefined} options.allowedSnippets An array that contains glob patterns.
  * @param {Object.<String, Function>} umbertoHelpers
  * @returns {Promise}
  */
@@ -80,9 +80,9 @@ module.exports = function snippetAdapter( snippets, options, umbertoHelpers ) {
 		snippets.add( snippetData );
 	}
 
-	// Remove snippets that do not match to patterns specified in `options.whitelistedSnippets`.
-	if ( options.whitelistedSnippets ) {
-		filterWhitelistedSnippets( snippets, options.whitelistedSnippets );
+	// Remove snippets that do not match to patterns specified in `options.allowedSnippets`.
+	if ( options.allowedSnippets ) {
+		filterAllowedSnippets( snippets, options.allowedSnippets );
 	}
 
 	console.log( `Found ${ snippets.size } "{@snippet ...}" tags...` );
@@ -215,13 +215,13 @@ module.exports = function snippetAdapter( snippets, options, umbertoHelpers ) {
 };
 
 /**
- * Removes snippets that names do not match to patterns specified in `whitelistedSnippets` array.
+ * Removes snippets that names do not match to patterns specified in `allowedSnippets` array.
  *
  * @param {Set.<Snippet>} snippets Snippet collection extracted from documentation files.
- * @param {Array.<String>|undefined} whitelistedSnippets Snippet patterns that should be built.
+ * @param {Array.<String>|undefined} allowedSnippets Snippet patterns that should be built.
  */
-function filterWhitelistedSnippets( snippets, whitelistedSnippets ) {
-	if ( !whitelistedSnippets.length ) {
+function filterAllowedSnippets( snippets, allowedSnippets ) {
+	if ( !allowedSnippets.length ) {
 		return;
 	}
 
@@ -229,7 +229,7 @@ function filterWhitelistedSnippets( snippets, whitelistedSnippets ) {
 
 	// Find all snippets that matched to specified criteria.
 	for ( const snippetData of snippets ) {
-		const shouldBeBuilt = whitelistedSnippets.some( pattern => {
+		const shouldBeBuilt = allowedSnippets.some( pattern => {
 			return minimatch( snippetData.snippetName, pattern ) || snippetData.snippetName.includes( pattern );
 		} );