refactor(User Config): Show config save error only with SLS_DEBUG=*

It's to not confuse users with warnings which do not affect
how application works

Fixes #7077
This commit is contained in:
Mariusz Nowak 2019-12-23 11:49:06 +01:00 committed by Mariusz Nowak
parent c88fae5724
commit bc04da5e41

View File

@ -23,10 +23,12 @@ function storeConfig(config) {
try {
writeFileAtomic.sync(serverlessrcPath, JSON.stringify(config, null, 2));
} catch (error) {
if (process.env.SLS_DEBUG) process.stdout.write(`${chalk.red(error.stack)}\n`);
process.stdout.write(
`Serverless: ${chalk.red(`Unable to store serverless config due to ${error.code} error`)}\n`
);
if (process.env.SLS_DEBUG) {
process.stdout.write(`${chalk.red(error.stack)}\n`);
process.stdout.write(
`Serverless: ${chalk.red(`Unable to store serverless config due to ${error.code} error`)}\n`
);
}
try {
return JSON.parse(readFileSync(serverlessrcPath));
} catch (readError) {