Skip to content

Commit

Permalink
[samp-local] - cherry pick functions to debug
Browse files Browse the repository at this point in the history
  • Loading branch information
ljacobsson committed Jul 28, 2023
1 parent a67b924 commit e739ea8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
1 change: 0 additions & 1 deletion src/commands/local/lib/connect.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ const mac = getMac();
let targetConfig = {};
if (fs.existsSync(`samconfig.toml`)) {
targetConfig = samConfigParser.parse();
console.log(targetConfig);
} else {
targetConfig = {
stack_name: process.env.SAMP_STACKNAME,
Expand Down
19 changes: 19 additions & 0 deletions src/shared/samConfigParser.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const toml = require('toml');
const fs = require('fs');
function parse() {
if (!fs.existsSync(`samconfig.toml`)) {
return {};
}
const configEnv = 'default';
const config = toml.parse(fs.readFileSync(`samconfig.toml`, 'utf-8'));
const envConfig = config[configEnv].deploy.parameters;
envConfig.configEnv = process.env.configEnv || 'default';
envConfig.stack_name = envConfig.stack_name || config[configEnv].global.parameters.stack_name
envConfig.region = envConfig.region || config[configEnv].global.parameters.region || process.env.AWS_REGION;
envConfig.profile = envConfig.profile || config[configEnv].global.parameters.profile || process.env.AWS_PROFILE;
return envConfig;
}

module.exports = {
parse
}

0 comments on commit e739ea8

Please sign in to comment.