update config

This commit is contained in:
davidwells 2017-05-23 19:57:22 -07:00
parent e91042194a
commit fd657fc4a8

View File

@ -8,24 +8,16 @@ const writeFileAtomic = require('write-file-atomic');
const getFrameworkId = require('../getFrameworkId');
const fileExistsSync = require('../fs/fileExistsSync');
const readFileSync = require('../fs/readFileSync');
const getServerlessDir = require('../getServerlessDir');
const isTrackingDisabled = require('../isTrackingDisabled');
const globalConfigPath = path.join(os.homedir(), '.serverlessrc');
function legacyIsTrackingDisabled() {
if (fileExistsSync(path.join(getServerlessDir(), 'stats-disabled'))) {
return true;
}
return false;
}
function createConfig() {
// set default config options
const config = {
userId: null, // currentUserId
frameworkId: getFrameworkId(),
settings: {
trackingDisabled: legacyIsTrackingDisabled(),
},
trackingDisabled: isTrackingDisabled(),
};
writeFileAtomic.sync(globalConfigPath, JSON.stringify(config, null, 2));
return JSON.parse(readFileSync(globalConfigPath));
@ -79,7 +71,7 @@ function deleteConfigValue(key) {
}
// set local config value /project/.serverlessrc
// function setLocalConfig
// function setLocalConfig() {}
// set .serverlessrc config value
function getConfigValue(objectPath) {
@ -95,5 +87,6 @@ module.exports = {
get: getConfigValue,
delete: deleteConfigValue,
getConfig,
getGlobalConfig,
CONFIG_FILE_PATH: globalConfigPath,
};