Skip to content

mheap/local-credentials

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

local-credentials

Read data out of an ini formatted ~/.local/credentials file e.g. ~/.aws/credentials

Build Status

Example Usage

You can use this library with either a Promise or a Callback based interface

async/await

async function main() {
    try {
        let Credentials = require("local-credentials");

        const c = new Credentials("~/.basic/credentials");
        const defaultData = await c.get(); // Returns the "default" section
        const specialData = await c.get("special"); // Returns the "special" section

        console.log(defaultData);
        console.log(specialData);
    } catch (err) {
        console.log(err);
    }
}

main();

Callback

let Credentials = require("local-credentials");

const c = new Credentials("~/.basic/credentials");
const defaultData = c.get("default", function(err, data){
    if (err){
        // Do something
    }
    console.log(data);
});