Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

examples: add scripts examples (js, ruby etc..) #27

Merged
merged 3 commits into from
Aug 31, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,22 @@ hello:
script: path/to/script.sh
```

Script paths are relative to the _config_ file, not the working directory.
If the script is executable, it is invoked directly, this allows you
to use `#!`:

```
$ echo -e '#!/usr/bin/env ruby\nputs "yo"' > yo.rb
$ chmod +x yo.rb
$ cat > robo.yml
yo:
summary: yo from rb
script: yo.rb
^C
$ robo yo
yo
```

Script paths are relative to the _config_ file, not the working directory.

### Usage

Expand Down
8 changes: 8 additions & 0 deletions _examples/scripts/scripts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

ruby:
summary: prints yo! from ruby
script: yo.rb

js:
summary: prints yo! from js
script: yo.js
3 changes: 3 additions & 0 deletions _examples/scripts/yo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env node

console.log("yo!")
3 changes: 3 additions & 0 deletions _examples/scripts/yo.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env ruby

puts "yo!"
10 changes: 8 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package main

import (
"path/filepath"

"github.com/tj/docopt"
"github.com/tj/robo/cli"
"github.com/tj/robo/config"
Expand Down Expand Up @@ -38,8 +40,12 @@ func main() {
cli.Fatalf("error parsing arguments: %s", err)
}

file := args["--config"].(string)
c, err := config.New(file)
abs, err := filepath.Abs(args["--config"].(string))
if err != nil {
cli.Fatalf("cannot resolve --config: %s", err)
}

c, err := config.New(abs)
if err != nil {
cli.Fatalf("error loading configuration: %s", err)
}
Expand Down