"use strict";

const fs   = require('fs');
const path = require('path');

function PluginPaths(profileRoot){
    this.root        = profileRoot;
    this.codeRoot    = path.join(profileRoot, 'plugins');
    this.dataRoot    = path.join(profileRoot, 'pluginData');
    this.installRoot = path.join(profileRoot, '.plugin-install');
    this.registry    = path.join(profileRoot, 'plugins.json');

    this.ensureDirs = function(){
        [ this.codeRoot, this.dataRoot, this.installRoot ].forEach(function(dir){
            fs.mkdirSync(dir, { recursive: true });
        });
    };
    this.pluginCode = function(id){ return path.join(this.codeRoot, id); };
    this.pluginData = function(id){ return path.join(this.dataRoot, id); };
}

module.exports = PluginPaths;
