@@ -35,7 +35,9 @@ const BUILD_DIR = 'build';
35
35
const SRC_DIR = 'src' ;
36
36
const ROOT_DIR = path . resolve ( __dirname , '..' ) ;
37
37
const 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 ) ;
39
41
const IGNORE_PATTERN = '**/__(mocks|snapshots|tests)__/**' ;
40
42
const FLOW_EXTENSION = '.flow' ;
41
43
@@ -103,7 +105,7 @@ function buildPackage(pkg) {
103
105
const pattern = path . resolve ( srcDir , '**/*' ) ;
104
106
const files = glob . sync ( pattern , { nodir : true } ) ;
105
107
106
- files . forEach ( ( file ) => buildFile ( file , true ) ) ;
108
+ files . forEach ( ( file ) => buildFile ( file , false ) ) ;
107
109
process . stdout . write ( `${ chalk . green ( '=>' ) } ${ path . basename ( pkg ) } (npm)\n` ) ;
108
110
}
109
111
@@ -115,14 +117,20 @@ function buildFile(file, silent) {
115
117
const destPath = path . resolve ( packageBuildPath , relativeToSrcPath ) ;
116
118
117
119
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 ) {
119
127
silent ||
120
128
process . stdout . write (
121
129
chalk . dim ( ' \u2022 ' ) +
122
130
path . relative ( PACKAGES_DIR , file ) +
123
131
' (ignore)\n'
124
132
) ;
125
- } else if ( ! micromatch . isMatch ( file , JS_FILES_PATTERN ) ) {
133
+ } else if ( isJS === false ) {
126
134
fs . createReadStream ( file ) . pipe ( fs . createWriteStream ( destPath ) ) ;
127
135
silent ||
128
136
process . stdout . write (
0 commit comments