gopkg.in/tools/godep.v21@v21.0.0-20151104013723-2cf1d6e3f557/util.go (about)

     1  package main
     2  
     3  import (
     4  	"fmt"
     5  	"os"
     6  	"os/exec"
     7  )
     8  
     9  // Runs a command in dir.
    10  // The name and args are as in exec.Command.
    11  // Stdout, stderr, and the environment are inherited
    12  // from the current process.
    13  func runIn(dir, name string, args ...string) error {
    14  	c := exec.Command(name, args...)
    15  
    16  	if verbose {
    17  		output, err := c.CombinedOutput()
    18  		fmt.Printf("execute %+v", c)
    19  		fmt.Printf(string(output))
    20  		if err != nil {
    21  			return fmt.Errorf("Error is %v", err)
    22  		}
    23  	}
    24  
    25  	c.Dir = dir
    26  	c.Stdout = os.Stdout
    27  	c.Stderr = os.Stderr
    28  	return c.Run()
    29  }