Ghost/core/server/utils/labs.js
Hannah Wolfe df82895db7 Move get helper behind labs flag
issue #5976

- break out the labs check into a utility
- wrap the get helper in a labs check, so it only works if the checkbox is checked
- make the get helper output an error to both the server and browser console if used when not enabled
2015-11-03 19:39:37 +00:00

21 lines
524 B
JavaScript

var _ = require('lodash'),
api = require('../api'),
flagIsSet;
flagIsSet = function flagIsSet(flag) {
return api.settings.read({key: 'labs', context: {internal: true}}).then(function (response) {
var labs,
labsValue;
labs = _.find(response.settings, function (setting) {
return setting.key === 'labs';
});
labsValue = JSON.parse(labs.value);
return !!labsValue[flag] && labsValue[flag] === true;
});
};
module.exports.isSet = flagIsSet;