1
0
mirror of https://github.com/StackExchange/dnscontrol.git synced 2024-05-11 05:55:12 +00:00

require() should handle paths as relative (like nodeJS) (#443)

* Integrate @nlowe's documentation and tests
* Use filepath.Clean() instead of filepath.Abs()
* Use a stackless implementation
This commit is contained in:
Tom Limoncelli
2019-01-29 10:29:00 -05:00
committed by GitHub
parent f9fc6243d4
commit 061ea63322
13 changed files with 171 additions and 21 deletions

View File

@@ -3,7 +3,6 @@ package commands
import (
"encoding/json"
"fmt"
"io/ioutil"
"os"
"github.com/StackExchange/dnscontrol/models"
@@ -101,11 +100,8 @@ func ExecuteDSL(args ExecuteDSLArgs) (*models.DNSConfig, error) {
if args.JSFile == "" {
return nil, errors.Errorf("No config specified")
}
text, err := ioutil.ReadFile(args.JSFile)
if err != nil {
return nil, errors.Errorf("Reading js file %s: %s", args.JSFile, err)
}
dnsConfig, err := js.ExecuteJavascript(string(text), args.DevMode)
dnsConfig, err := js.ExecuteJavascript(args.JSFile, args.DevMode)
if err != nil {
return nil, errors.Errorf("Executing javascript in %s: %s", args.JSFile, err)
}