Comparing version 0.0.10 to 0.0.11
@@ -181,5 +181,6 @@ #!/usr/bin/env node | ||
const idMap = new Map(); | ||
function getRequire(baseDir) { | ||
function getRequire(baseDir, callerProfile) { | ||
return ((name, profile) => { | ||
const lisp = getInterpreter(profile || profileName, lsxBootPath); | ||
profile = profile || callerProfile; | ||
const lisp = getInterpreter(profile, lsxBootPath); | ||
let id = void 0; | ||
@@ -204,3 +205,3 @@ if (name.startsWith('./') || name.startsWith('../')) { | ||
const c = io.readFromFileSync(id); | ||
lisp.setGlobals(getGlobals(path.dirname(id), path.basename(id))); | ||
lisp.setGlobals(getGlobals(path.dirname(id), path.basename(id), profile)); | ||
const r = lisp(c); | ||
@@ -213,3 +214,3 @@ idMap.set(id, r); | ||
function getGlobals(baseDir, moduleName) { | ||
function getGlobals(baseDir, moduleName, profile) { | ||
return Object.assign({}, { | ||
@@ -219,4 +220,5 @@ '$argv': appOpts, | ||
'$__filename': path.join(baseDir, moduleName), | ||
'$__profile': profile, | ||
}, safe ? {} : { | ||
'$require': getRequire(baseDir), | ||
'$require': getRequire(baseDir, profile), | ||
'$node-require': (name) => { | ||
@@ -254,3 +256,3 @@ let id = name; | ||
const codes = await getCodes(); | ||
lisp.setGlobals(getGlobals(cwd, '__entrypoint__')); | ||
lisp.setGlobals(getGlobals(cwd, '__entrypoint__', profileName)); | ||
await repl.startRepl(liyad.S, lisp, codes); | ||
@@ -268,4 +270,4 @@ } catch (e) { | ||
lisp.setGlobals(fns.length > 0 ? | ||
getGlobals(path.dirname(fns[fns.length - 1]), path.basename(fns[fns.length - 1])) : | ||
getGlobals(cwd, '__entrypoint__')); | ||
getGlobals(path.dirname(fns[fns.length - 1]), path.basename(fns[fns.length - 1]), profileName) : | ||
getGlobals(cwd, '__entrypoint__'), profileName); | ||
let r = await lisp(codes); | ||
@@ -272,0 +274,0 @@ switch (typeof r) { |
{ | ||
"name": "liyad-cli", | ||
"version": "0.0.10", | ||
"version": "0.0.11", | ||
"description": "CLI and REPL for Liyad (Lisp yet another DSL interpreter).", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
30054
553