Created
April 7, 2016 13:45
-
-
Save harish2704/5bcf6c33ba3713ffef3a92a0d6131edc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var HOME = process.env.HOME; | |
var CONFIG_DIR = `${HOME}/.config/chromium/`; | |
var fs = require('fs'); | |
function listProfileDirs( ){ | |
return fs.readdirSync( CONFIG_DIR ).filter( ( dirName) => { | |
return dirName.match( 'Profile ' ); | |
}) | |
} | |
function getProfileName( dirName ){ | |
var prefs = fs.readFileSync( `${CONFIG_DIR}/${dirName}/Preferences` ); | |
prefs = JSON.parse( prefs ); | |
return prefs.profile.name; | |
} | |
function getNamePathMap( ){ | |
return listProfileDirs().map( (v) =>{ | |
return { | |
name: getProfileName( v ), | |
path: v, | |
}}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment