diff --git a/lib/atom-python-run.js b/lib/atom-python-run.js index 17b4c47..e919841 100644 --- a/lib/atom-python-run.js +++ b/lib/atom-python-run.js @@ -31,7 +31,7 @@ module.exports = { 'command': atom.config.get(`atom-python-run.${key}Command`), 'pause': atom.config.get(`atom-python-run.${key}Pause`), }); - } + } } catch(error) { // the promise failed and the exception was caught console.log(`atom-python-run: saveAndRun: ${error}`); @@ -48,14 +48,32 @@ module.exports = { let args = config.command.split(' '); // load configuration settings in to 'config' object + config = Object.assign(config, { 'terminal': atom.config.get('atom-python-run.terminal'), 'pipeFile': atom.config.get('atom-python-run.pipeFile'), 'pipePath': atom.config.get('atom-python-run.pipePath'), 'extensions': atom.config.get('atom-python-run.extensionFilter'), - 'consoleLog': atom.config.get('atom-python-run.consoleLog') + 'consoleLog': atom.config.get('atom-python-run.consoleLog'), + 'f5envVariables': atom.config.get('atom-python-run.f5envVariables') // Environment Variables }); + let tmpEnv = {}; + var tmpArr = [] + + // Extracting the env Variables from array format + + for (var i = 0; i < config.f5envVariables.length; i++) { + if(config.f5envVariables[i].includes(":")){ + tmpArr = config.f5envVariables[i].split(":") + if(tmpArr.length==2){ + tmpEnv[tmpArr[0]] = tmpArr[1]; + } + } + } + + // console.log(tmpEnv); + function format(string, object) { return string.replace(/{.*?}/g, (element) => object[element.substring(1, element.length - 1)] @@ -118,7 +136,8 @@ module.exports = { 'args': args, 'options': { cwd: info.dir, - detached: true + detached: true, + env: tmpEnv // Passing Environment variables to the shell instance } }); @@ -160,6 +179,16 @@ module.exports = { type: 'string', default: 'python {file}' }, + /////// Env Variables option + f5envVariables: { + title: 'Environment Variables', + description: 'format [key:pair, key:pair ...]', + type: 'array', + default: [], + items:{ + type: "string" + } + }, f6Command: { title: 'F6 Command', description: 'Same as above',