@@ -192,50 +192,48 @@ function copyNodePackageTemplate(packageName) {
192
192
`'files' field is missing from package.json in package ${ packageName } `
193
193
) ;
194
194
process . exit ( 1 ) ;
195
- } else {
196
- // 'files' field exists in package.json,
197
- fs . mkdirSync ( to ) ;
198
- let existingDirCache = { } ;
199
- // looping through entries(single file / directory / pattern) in `files`
200
- const whitelistedFiles = whitelist . reduce ( ( list , pattern ) => {
201
- const matchedFiles = glob . sync ( pattern , {
202
- cwd : npmFrom ,
203
- } ) ;
204
- // copy matching files/directories from './npm' to build package.
205
- matchedFiles . forEach ( file => {
206
- if ( fs . lstatSync ( `${ npmFrom } /${ file } ` ) . isFile ( ) ) {
207
- // copy source is a file, create all nesting directories ahead
208
- // to avoid 'No such file or directory' error
209
- const fileDirnameSegments = dirname ( file ) . split ( '/' ) ;
210
- fileDirnameSegments . reduce ( ( prevPath , currentPath ) => {
211
- const fullPath = `${ prevPath } /${ currentPath } ` ;
212
- if ( ! existingDirCache [ fullPath ] && ! fs . existsSync ( fullPath ) ) {
213
- existingDirCache [ fullPath ] = true ;
214
- fs . mkdirSync ( `${ to } /${ fullPath } ` ) ;
215
- }
216
- return fullPath ;
217
- } , '' ) ;
218
- }
219
- promisesForForwardingModules . push (
220
- asyncCopyTo ( `${ npmFrom } /${ file } ` , `${ to } /${ file } ` )
221
- ) ;
222
- } ) ;
223
- // return an array of whitelisted files
224
- // for entry point check next.
225
- // All patterns have been parsed to file/directory
226
- return list . concat ( matchedFiles ) ;
227
- } , [ ] ) ;
228
- // terminate the build if any entry point(Exception: *.fb.js)
229
- // is not whitelisted in the 'files' field in package.json.
230
- packageEntries . forEach ( entry => {
231
- if ( ! whitelistedFiles . includes ( entry ) ) {
232
- console . error (
233
- `Entry point ${ entry } in package ${ packageName } is not listed in the 'files' field in package.json`
234
- ) ;
235
- process . exit ( 1 ) ;
195
+ }
196
+ fs . mkdirSync ( to ) ;
197
+ let existingDirCache = { } ;
198
+ // looping through entries(single file / directory / pattern) in `files`
199
+ const whitelistedFiles = whitelist . reduce ( ( list , pattern ) => {
200
+ const matchedFiles = glob . sync ( pattern , {
201
+ cwd : npmFrom ,
202
+ } ) ;
203
+ // copy matching files/directories from './npm' to build package.
204
+ matchedFiles . forEach ( file => {
205
+ if ( fs . lstatSync ( `${ npmFrom } /${ file } ` ) . isFile ( ) ) {
206
+ // copy source is a file, create all nesting directories ahead
207
+ // to avoid 'No such file or directory' error
208
+ const fileDirnameSegments = dirname ( file ) . split ( '/' ) ;
209
+ fileDirnameSegments . reduce ( ( prevPath , currentPath ) => {
210
+ const fullPath = `${ prevPath } /${ currentPath } ` ;
211
+ if ( ! existingDirCache [ fullPath ] && ! fs . existsSync ( fullPath ) ) {
212
+ existingDirCache [ fullPath ] = true ;
213
+ fs . mkdirSync ( `${ to } /${ fullPath } ` ) ;
214
+ }
215
+ return fullPath ;
216
+ } , '' ) ;
236
217
}
218
+ promisesForForwardingModules . push (
219
+ asyncCopyTo ( `${ npmFrom } /${ file } ` , `${ to } /${ file } ` )
220
+ ) ;
237
221
} ) ;
238
- }
222
+ // return an array of whitelisted files
223
+ // for entry point check next.
224
+ // All patterns have been parsed to file/directory
225
+ return list . concat ( matchedFiles ) ;
226
+ } , [ ] ) ;
227
+ // terminate the build if any entry point(Exception: *.fb.js)
228
+ // is not whitelisted in the 'files' field in package.json.
229
+ packageEntries . forEach ( entry => {
230
+ if ( ! whitelistedFiles . includes ( entry ) ) {
231
+ console . error (
232
+ `Entry point ${ entry } in package ${ packageName } is not listed in the 'files' field in package.json`
233
+ ) ;
234
+ process . exit ( 1 ) ;
235
+ }
236
+ } ) ;
239
237
return Promise . all ( [
240
238
...promisesForForwardingModules ,
241
239
asyncCopyTo ( resolve ( `${ from } /package.json` ) , `${ to } /package.json` ) ,
0 commit comments