From 8548379e97d9677b5e46ca35cb85e4649f11f481 Mon Sep 17 00:00:00 2001 From: Jackie6 <541172791@qq.com> Date: Fri, 15 Mar 2019 20:11:31 +0000 Subject: [PATCH] Exculde test files when rebuilding packages --- bin/packages/watch.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bin/packages/watch.js b/bin/packages/watch.js index fce8a6beedb977..dcbacb81d671e3 100644 --- a/bin/packages/watch.js +++ b/bin/packages/watch.js @@ -23,9 +23,11 @@ const exists = ( filename ) => { return false; }; -// Exclude deceitful source-like files, such as editor swap files. +// Exclude test files including .js files inside of __tests__ or test folders +// and files with a suffix of .test or .spec (e.g. blocks.test.js), +// and deceitful source-like files, such as editor swap files. const isSourceFile = ( filename ) => { - return /.\.(js|scss)$/.test( filename ); + return ! [ /\/(__tests__|test)\/.+.js$/, /.\.(spec|test)\.js$/ ].some( ( regex ) => regex.test( filename ) ) && /.\.(js|scss)$/.test( filename ); }; const rebuild = ( filename ) => filesToBuild.set( filename, true );