@@ -35,7 +35,9 @@ const BUILD_DIR = 'build';
3535const SRC_DIR = 'src' ;
3636const ROOT_DIR = path . resolve ( __dirname , '..' ) ;
3737const PACKAGES_DIR = path . resolve ( ROOT_DIR , 'packages' ) ;
38- const JS_FILES_PATTERN = path . resolve ( PACKAGES_DIR , '**/*.js' ) ;
38+ const JS_FILES_PATTERN = path . resolve ( PACKAGES_DIR , '**/*.js' )
39+ . split ( path . sep )
40+ . join ( path . posix . sep ) ;
3941const IGNORE_PATTERN = '**/__(mocks|snapshots|tests)__/**' ;
4042const FLOW_EXTENSION = '.flow' ;
4143
@@ -103,7 +105,7 @@ function buildPackage(pkg) {
103105 const pattern = path . resolve ( srcDir , '**/*' ) ;
104106 const files = glob . sync ( pattern , { nodir : true } ) ;
105107
106- files . forEach ( ( file ) => buildFile ( file , true ) ) ;
108+ files . forEach ( ( file ) => buildFile ( file , false ) ) ;
107109 process . stdout . write ( `${ chalk . green ( '=>' ) } ${ path . basename ( pkg ) } (npm)\n` ) ;
108110}
109111
@@ -115,14 +117,20 @@ function buildFile(file, silent) {
115117 const destPath = path . resolve ( packageBuildPath , relativeToSrcPath ) ;
116118
117119 mkdirp . sync ( path . dirname ( destPath ) ) ;
118- if ( micromatch . isMatch ( file , IGNORE_PATTERN ) ) {
120+
121+ const isIgnored = micromatch . isMatch ( file , IGNORE_PATTERN ) ;
122+ // normalize paths to using posix format
123+ const normalizedPath = file . split ( path . sep ) . join ( path . posix . sep ) ;
124+ const isJS = micromatch . isMatch ( normalizedPath , JS_FILES_PATTERN ) ;
125+
126+ if ( isIgnored ) {
119127 silent ||
120128 process . stdout . write (
121129 chalk . dim ( ' \u2022 ' ) +
122130 path . relative ( PACKAGES_DIR , file ) +
123131 ' (ignore)\n'
124132 ) ;
125- } else if ( ! micromatch . isMatch ( file , JS_FILES_PATTERN ) ) {
133+ } else if ( isJS === false ) {
126134 fs . createReadStream ( file ) . pipe ( fs . createWriteStream ( destPath ) ) ;
127135 silent ||
128136 process . stdout . write (
0 commit comments