37 lines
929 B
JavaScript
37 lines
929 B
JavaScript
'use strict';
|
|
|
|
var fs = require('fs');
|
|
var path = require('path');
|
|
|
|
module.exports = {
|
|
directives: {
|
|
_get: function (providerUri) {
|
|
// TODO make safe
|
|
try {
|
|
return require(path.join(process.cwd(), providerUri + '.directives.json'));
|
|
} catch(e) {
|
|
return null;
|
|
}
|
|
}
|
|
, _set: function (providerUri, directives) {
|
|
fs.writeFileSync(path.join(process.cwd(), providerUri + '.directives.json'), JSON.stringify(directives, null, 2));
|
|
return directives;
|
|
}
|
|
}
|
|
|
|
, session: {
|
|
_get: function (providerUri) {
|
|
// TODO make safe
|
|
try {
|
|
return require(path.join(process.cwd(), providerUri + '.session.json'));
|
|
} catch(e) {
|
|
return null;
|
|
}
|
|
}
|
|
, _set: function (providerUri, session) {
|
|
fs.writeFileSync(path.join(process.cwd(), providerUri + '.session.json'), JSON.stringify(session, null, 2));
|
|
return session;
|
|
}
|
|
}
|
|
};
|