Skip to content

Commit

Permalink
Working in windows (.cmd instead of .do). Rename fails
Browse files Browse the repository at this point in the history
(golang/go#8914) if destination exists.
  • Loading branch information
luis committed Apr 4, 2015
1 parent c36ac80 commit 3b45175
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 20 deletions.
2 changes: 1 addition & 1 deletion common.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

const (
// TASK_PREFIX is a marker for scripts that don't produce content.
TASK_PREFIX = '@'
TASK_PREFIX = '_'

// REDO_DIR names the hidden directory used for data and configuration.
REDO_DIR = ".redo"
Expand Down
13 changes: 7 additions & 6 deletions dofile.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ extension removed.
*/
func (f *File) findDoFile() (*DoInfo, error) {

candidates := []string{f.Name + ".do"}
candidates := []string{f.Name + ".cmd"}
ext := strings.Split(f.Name, ".")
for i := 0; i < len(ext); i++ {
candidates = append(candidates, strings.Join(append(append([]string{"default"}, ext[i+1:]...), "do"), "."))
Expand Down Expand Up @@ -70,7 +70,7 @@ TOP:
return &DoInfo{Missing: missing}, nil
}

const shell = "/bin/sh"
const shell = "cmd.exe"

// RunDoFile executes the do file script, records the metadata for the resulting output, then
// saves the resulting output to the target file, if applicable.
Expand Down Expand Up @@ -156,6 +156,7 @@ func (target *File) RunDoFile(doInfo *DoInfo) (err error) {
return target.Errorf(".do file %s wrote to stdout and to file $3", target.DoFile)
}

os.Remove(target.Fullpath()) //LOC
err = os.Rename(out.Name(), target.Fullpath())

if err != nil && strings.Index(err.Error(), "cross-device") > -1 {
Expand All @@ -180,12 +181,12 @@ func (target *File) RunDoFile(doInfo *DoInfo) (err error) {

func (target *File) runCmd(outputs [2]*Output, doInfo *DoInfo) error {

args := []string{"-e"}
args := []string{"/c"}

if ShellArgs != "" {
if ShellArgs[0] != '-' {
ShellArgs = "-" + ShellArgs
}
//if ShellArgs[0] != '-' {
// ShellArgs = "-" + ShellArgs
//}
args = append(args, ShellArgs)
}

Expand Down
4 changes: 2 additions & 2 deletions redux/ifx.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"fmt"
"os"

"github.com/gyepisam/redux"
"github.com/maqroll/redux"
)

var cmdIfCreate = &Command{
Expand Down Expand Up @@ -56,7 +56,7 @@ func redoIfX(args []string, fn func(*redux.File, *redux.File) error) error {
}

wd := os.Getenv("REDO_PARENT_DIR")

// The action is triggered by dependent.
dependent, err := redux.NewFile(wd, dependentPath)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion redux/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"os"

"github.com/gyepisam/redux"
"github.com/maqroll/redux"
)

var cmdInit = &Command{
Expand Down
2 changes: 1 addition & 1 deletion redux/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"strings"
)

const docPkg = "github.com/gyepisam/redux"
const docPkg = "github.com/maqroll/redux"

var cmdInstall = &Command{
UsageLine: "redux install [OPTIONS] [component, ...]",
Expand Down
14 changes: 6 additions & 8 deletions redux/redo.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import (

"github.com/gyepisam/fileutils"
"github.com/gyepisam/multiflag"
"github.com/gyepisam/redux"
"github.com/maqroll/redux"
)

const (
DEFAULT_TARGET = string(redux.TASK_PREFIX) + "all"
DEFAULT_DO = DEFAULT_TARGET + ".do"
DEFAULT_DO = DEFAULT_TARGET + ".cmd"
)

var cmdRedo = &Command{
Expand Down Expand Up @@ -77,11 +77,10 @@ func runRedo(targets []string) error {
redux.ShellArgs = s
}

// if shell args are set, ensure that at least minimal verbosity is also set.
if redux.ShellArgs != "" && (verbosity.NArg() == 0) {
verbosity.Set("true")
}

// if shell args are set, ensure that at least minimal verbosity is also set.
if redux.ShellArgs != "" && (verbosity.NArg() == 0) {
verbosity.Set("true")
}

// Set explicit options to avoid clobbering environment inherited options.
if n := verbosity.NArg(); n > 0 {
Expand All @@ -94,7 +93,6 @@ func runRedo(targets []string) error {
redux.Debug = true
}


// If no arguments are specified, use run default target if its .do file exists.
// Otherwise, print usage and exit.
if len(targets) == 0 {
Expand Down
2 changes: 1 addition & 1 deletion z_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func init() {

bin := filepath.Join(binDir, "/redux")

err = exec.Command("go", "build", "-o", bin, "github.com/gyepisam/redux/redux").Run()
err = exec.Command("go", "build", "-o", bin, "github.com/maqroll/redux/redux").Run()
if err != nil {
panic(err)
}
Expand Down

0 comments on commit 3b45175

Please sign in to comment.