@@ -278,6 +278,8 @@ if (specified["self"]) {
278
278
if ( paths . length ) UglifyJS . AST_Node . warn ( "Ignoring input files since --self was passed" ) ;
279
279
if ( ! options . wrap ) options . wrap = "UglifyJS" ;
280
280
paths = UglifyJS . FILES ;
281
+ } else if ( paths . length ) {
282
+ paths = simple_glob ( paths ) ;
281
283
}
282
284
if ( specified [ "in-situ" ] ) {
283
285
if ( output && output != "spidermonkey" || specified [ "reduce-test" ] || specified [ "self" ] ) {
@@ -292,7 +294,7 @@ if (specified["in-situ"]) {
292
294
run ( ) ;
293
295
} ) ;
294
296
} else if ( paths . length ) {
295
- simple_glob ( paths ) . forEach ( function ( name ) {
297
+ paths . forEach ( function ( name ) {
296
298
files [ convert_path ( name ) ] = read_file ( name ) ;
297
299
} ) ;
298
300
run ( ) ;
@@ -491,33 +493,42 @@ function fatal(message) {
491
493
492
494
// A file glob function that only supports "*" and "?" wildcards in the basename.
493
495
// Example: "foo/bar/*baz??.*.js"
494
- // Argument `glob` may be a string or an array of strings.
496
+ // Argument `paths` must be an array of strings.
495
497
// Returns an array of strings. Garbage in, garbage out.
496
- function simple_glob ( glob ) {
497
- if ( Array . isArray ( glob ) ) {
498
- return [ ] . concat . apply ( [ ] , glob . map ( simple_glob ) ) ;
499
- }
500
- if ( glob . match ( / \* | \? / ) ) {
501
- var dir = path . dirname ( glob ) ;
502
- try {
503
- var entries = fs . readdirSync ( dir ) ;
504
- } catch ( ex ) { }
505
- if ( entries ) {
506
- var pattern = "^" + path . basename ( glob )
507
- . replace ( / [ . + ^ $ [ \] \\ ( ) { } ] / g, "\\$&" )
508
- . replace ( / \* / g, "[^/\\\\]*" )
509
- . replace ( / \? / g, "[^/\\\\]" ) + "$" ;
510
- var mod = process . platform === "win32" ? "i" : "" ;
511
- var rx = new RegExp ( pattern , mod ) ;
512
- var results = entries . sort ( ) . filter ( function ( name ) {
513
- return rx . test ( name ) ;
514
- } ) . map ( function ( name ) {
515
- return path . join ( dir , name ) ;
516
- } ) ;
517
- if ( results . length ) return results ;
498
+ function simple_glob ( paths ) {
499
+ return paths . reduce ( function ( paths , glob ) {
500
+ if ( / \* | \? / . test ( glob ) ) {
501
+ var dir = path . dirname ( glob ) ;
502
+ try {
503
+ var entries = fs . readdirSync ( dir ) . filter ( function ( name ) {
504
+ try {
505
+ return fs . statSync ( path . join ( dir , name ) ) . isFile ( ) ;
506
+ } catch ( ex ) {
507
+ return false ;
508
+ }
509
+ } ) ;
510
+ } catch ( ex ) { }
511
+ if ( entries ) {
512
+ var pattern = "^" + path . basename ( glob )
513
+ . replace ( / [ . + ^ $ [ \] \\ ( ) { } ] / g, "\\$&" )
514
+ . replace ( / \* / g, "[^/\\\\]*" )
515
+ . replace ( / \? / g, "[^/\\\\]" ) + "$" ;
516
+ var mod = process . platform === "win32" ? "i" : "" ;
517
+ var rx = new RegExp ( pattern , mod ) ;
518
+ var results = entries . filter ( function ( name ) {
519
+ return rx . test ( name ) ;
520
+ } ) . sort ( ) . map ( function ( name ) {
521
+ return path . join ( dir , name ) ;
522
+ } ) ;
523
+ if ( results . length ) {
524
+ [ ] . push . apply ( paths , results ) ;
525
+ return paths ;
526
+ }
527
+ }
518
528
}
519
- }
520
- return [ glob ] ;
529
+ paths . push ( glob ) ;
530
+ return paths ;
531
+ } , [ ] ) ;
521
532
}
522
533
523
534
function read_file ( path , default_value ) {
0 commit comments