var os = require('os');
var path = require('path');
var osenv = require('osenv');

// Assume XDG defaults
// See: http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
var paths = {
    config: process.env.XDG_CONFIG_HOME,
    data: process.env.XDG_DATA_HOME,
    cache: process.env.XDG_CACHE_HOME
};

// Guess some needed properties based on the user OS
var temp = os.tmpdir ? os.tmpdir() : os.tmpDir();
var home = osenv.home();
var base;

// Fallbacks for windows
if (process.platform === 'win32') {
    base = path.resolve(process.env.APPDATA || home || temp);
    base = path.join(base, 'bower');

    paths.config = paths.config || path.join(base, 'config');
    paths.data = paths.data || path.join(base, 'data');
    paths.cache = paths.cache || path.join(base, 'cache');
// Fallbacks for other operating systems
} else {
    base = path.resolve(home || temp);

    paths.config = paths.config || path.join(base, '.config/bower');
    paths.data = paths.data || path.join(base, '.local/share/bower');
    paths.cache = paths.cache || path.join(base, '.cache/bower');
}

module.exports = paths;

var os = require('os');
var path = require('path');
var osenv = require('osenv');

// Assume XDG defaults
// See: http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
var paths = {
    config: process.env.XDG_CONFIG_HOME,
    data: process.env.XDG_DATA_HOME,
    cache: process.env.XDG_CACHE_HOME
};

// Guess some needed properties based on the user OS
var user = (osenv.user() || 'unkown').replace(/\\/g, '-');
var temp = path.join(os.tmpdir ? os.tmpdir() : os.tmpDir(), user);
var home = osenv.home();
var base;

// Fallbacks for windows
if (process.platform === 'win32') {
    base = path.resolve(process.env.APPDATA || home || temp);
    base = path.join(base, 'bower');

    paths.config = paths.config || path.join(base, 'config');
    paths.data = paths.data || path.join(base, 'data');
    paths.cache = paths.cache || path.join(base, 'cache');
// Fallbacks for other operating systems
} else {
    base = path.resolve(home || temp);

    paths.config = paths.config || path.join(base, '.config/bower');
    paths.data = paths.data || path.join(base, '.local/share/bower');
    paths.cache = paths.cache || path.join(base, '.cache/bower');
}

module.exports = paths;

Append the username when using the temporary folder.
Append the username when using the temporary folder.
