mib-cli
Version:
CLI tool to manage projects
46 lines (37 loc) • 729 B
JavaScript
module.exports = (function() {
let self = this;
let storage;
let vorpal;
function init(vorpal) {
self.vorpal = vorpal;
self.storage = vorpal.localStorage;
}
function getConfig() {
let config = self.storage.getItem('mib-config');
return config ? JSON.parse(config) : {};
};
function setConfig(config) {
config = config || {};
self.storage.setItem('mib-config', JSON.stringify(config));
};
return {
root(root) {
// Getter
if(root === undefined)
return getConfig().root;
// Setter
else {
let config = getConfig()
config.root = root;
setConfig(config);
return root;
}
},
cwd() {
return process.cwd();
},
setVorpal(vorpal) {
init(vorpal);
}
};
})();