@@ -78,8 +78,9 @@ func NewTask(root, input, output string) (Task, error) {
78
78
}
79
79
80
80
var (
81
- Error * log.Logger
82
- Info * log.Logger
81
+ Error * log.Logger
82
+ Warning * log.Logger
83
+ Info * log.Logger
83
84
)
84
85
85
86
func main () {
@@ -150,6 +151,7 @@ func run() int {
150
151
useStdin := len (inputs ) == 0
151
152
152
153
Error = log .New (os .Stderr , "ERROR: " , 0 )
154
+ Warning = log .New (os .Stderr , "WARNING: " , 0 )
153
155
if verbose {
154
156
Info = log .New (os .Stderr , "" , 0 )
155
157
} else {
@@ -320,7 +322,7 @@ func run() int {
320
322
}
321
323
322
324
// concatenate
323
- if 1 < len (tasks ) && ! dirDst {
325
+ if 1 < len (tasks ) && bundle {
324
326
// Task.sync == false because dirDst == false
325
327
for _ , task := range tasks [1 :] {
326
328
tasks [0 ].srcs = append (tasks [0 ].srcs , task .srcs [0 ])
@@ -408,9 +410,9 @@ func run() int {
408
410
}
409
411
}
410
412
411
- // skip files in output directory (which is also an input directory) for the first change
412
- // skips files that are not minified and stay put, as they are not explicitly copied, but that's ok
413
413
if autoDir && root == output {
414
+ // skip files in output directory (which is also an input directory) for the first change
415
+ // skips files that are not minified and stay put as they are not explicitly copied, but that's ok
414
416
if _ , ok := skip [file ]; ! ok {
415
417
skip [file ] = true
416
418
break
@@ -437,7 +439,7 @@ func run() int {
437
439
}
438
440
439
441
if verbose && ! watch {
440
- Info .Println (time .Since (start ), "total" )
442
+ Info .Println ("finished in" , time .Since (start ))
441
443
}
442
444
if 0 < fails {
443
445
return 1
@@ -502,48 +504,36 @@ func createTasks(inputs []string, output string) ([]Task, []string, error) {
502
504
503
505
if info .Mode ().IsRegular () {
504
506
if sync || fileMatches (info .Name ()) {
505
- task , err := NewTask ("" , input , output )
507
+ task , err := NewTask (filepath . Dir ( input ) , input , output )
506
508
if err != nil {
507
509
return nil , nil , err
508
510
}
509
511
tasks = append (tasks , task )
510
512
}
511
513
} else if info .Mode ().IsDir () {
512
- roots = append (roots , input )
513
514
if ! recursive {
514
- infos , err := ioutil .ReadDir (input )
515
+ Warning .Println ("--recursive not specified, omitting directory" , input )
516
+ continue
517
+ }
518
+ roots = append (roots , input )
519
+ err := filepath .Walk (input , func (path string , info os.FileInfo , err error ) error {
515
520
if err != nil {
516
- return nil , nil , err
517
- }
518
- for _ , info := range infos {
519
- if validFile (info ) && (sync || fileMatches (info .Name ())) {
520
- task , err := NewTask (input , path .Join (input , info .Name ()), output )
521
- if err != nil {
522
- return nil , nil , err
523
- }
524
- tasks = append (tasks , task )
525
- }
521
+ return err
526
522
}
527
- } else {
528
- err := filepath .Walk (input , func (path string , info os.FileInfo , err error ) error {
523
+ path = sanitizePath (path )
524
+ if validFile (info ) && (sync || fileMatches (info .Name ())) {
525
+ task , err := NewTask (input , path , output )
529
526
if err != nil {
530
527
return err
531
528
}
532
- path = sanitizePath (path )
533
- if validFile (info ) && (sync || fileMatches (info .Name ())) {
534
- task , err := NewTask (input , path , output )
535
- if err != nil {
536
- return err
537
- }
538
- tasks = append (tasks , task )
539
- } else if info .Mode ().IsDir () && ! validDir (info ) && info .Name () != "." && info .Name () != ".." { // check for IsDir, so we don't skip the rest of the directory when we have an invalid file
540
- return filepath .SkipDir
541
- }
542
- return nil
543
- })
544
- if err != nil {
545
- return nil , nil , err
529
+ tasks = append (tasks , task )
530
+ } else if info .Mode ().IsDir () && ! validDir (info ) && info .Name () != "." && info .Name () != ".." { // check for IsDir, so we don't skip the rest of the directory when we have an invalid file
531
+ return filepath .SkipDir
546
532
}
533
+ return nil
534
+ })
535
+ if err != nil {
536
+ return nil , nil , err
547
537
}
548
538
} else {
549
539
return nil , nil , fmt .Errorf ("not a file or directory %s" , input )
0 commit comments