Comparing version 0.8.1 to 0.8.2
33
conf.js
@@ -28,5 +28,2 @@ // | ||
const createScript = require("vm").createScript | ||
, readFileSync = require("fs").readFileSync | ||
, statSync = require("fs").statSync | ||
, readdirSync = require("fs").readdirSync | ||
, join = require("path").join | ||
@@ -89,19 +86,15 @@ , normalize = require("path").normalize | ||
return context; | ||
} | ||
}; | ||
exports.createScript = function(path, filename) { | ||
var resolvedPath; | ||
exports.createScript = function(code, filename) { | ||
var script; | ||
resolvedPath = resolvePath(path, process.cwd()); | ||
script = new Script(resolvedPath, filename); | ||
script = new Script(code, filename); | ||
return script; | ||
} | ||
}; | ||
function Script(path, filename) { | ||
this.code = readFileSync(path, "utf8"); | ||
this.filename = filename || basename(path); | ||
this.workdir = dirname(path); | ||
function Script(code, filename) { | ||
this.code = code | ||
this.filename = filename | ||
this.workdir = process.cwd(); | ||
this.strict = false; | ||
@@ -216,3 +209,3 @@ this.paths = []; | ||
try { | ||
stat = statSync(path); | ||
stat = require("fs").statSync(path); | ||
return kind == "dir" ? stat.isDirectory() : stat.isFile(); | ||
@@ -255,3 +248,3 @@ } catch(e) { | ||
try { | ||
files = readdirSync(dirpath); | ||
files = require("fs").readdirSync(dirpath); | ||
} catch (listException) { | ||
@@ -374,5 +367,6 @@ return null; | ||
var msg; | ||
var code; | ||
try { | ||
script = new Script(p); | ||
code = require("fs").readFileSync(p, "utf8"); | ||
} catch (ioException) { | ||
@@ -382,2 +376,5 @@ throw new RuntimeError(self, msg); | ||
script = new Script(code, basename(p)); | ||
script.workdir = dirname(p); | ||
runtime = new Runtime( script | ||
@@ -384,0 +381,0 @@ , self.context |
{ | ||
"name": "conf", | ||
"version": "0.8.1", | ||
"version": "0.8.2", | ||
"description": "Config library for Nodejs", | ||
@@ -8,3 +8,3 @@ "keywords": ["dsl", "conf", "config", "script", "general"], | ||
"author": "Johan Dahlberg <dahlberg.johan@gmail.com> (https://github.com/jfd/)", | ||
"main": "conf", | ||
"main": "./conf", | ||
"repository": { | ||
@@ -11,0 +11,0 @@ "type": "git", |
38911
852