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

@@ -1,2 +1,2 @@
require("pkg/js/parse_tests/import.js")
require("./import.js")

View File

@@ -0,0 +1 @@
require('./complexImports/base.js');

View File

@@ -0,0 +1,38 @@
{
"registrars": [],
"dns_providers": [],
"domains": [
{
"name": "foo.com",
"registrar": "none",
"dnsProviders": {},
"records": [
{
"type": "A",
"name": "@",
"target": "1.2.3.4"
},
{
"type": "CNAME",
"name": "A",
"target": "foo.com."
},
{
"type": "CNAME",
"name": "C",
"target": "foo.com."
},
{
"type": "CNAME",
"name": "D",
"target": "foo.com."
},
{
"type": "CNAME",
"name": "B",
"target": "foo.com."
}
]
}
]
}

View File

@@ -0,0 +1,3 @@
function a() {
return CNAME("A", "foo.com.")
}

View File

@@ -0,0 +1,8 @@
require('../a.js');
function c() {
return [
a(),
CNAME("C", "foo.com.")
]
}

View File

@@ -0,0 +1,8 @@
require('pkg/js/parse_tests/complexImports/b/d/d.js');
function b() {
return [
d(),
CNAME("B", "foo.com.")
];
}

View File

@@ -0,0 +1,3 @@
function d() {
return CNAME("D", "foo.com.")
}

View File

@@ -0,0 +1,8 @@
require('./a/c/c.js');
require('./b/b.js');
D("foo.com","none",
A("@","1.2.3.4"),
c(),
b()
);