From 5bc821e7f0d8e3a4a54d5354756aeb290c85149f Mon Sep 17 00:00:00 2001 From: Manuel Fernandez Date: Tue, 29 Sep 2020 10:33:33 -0500 Subject: [PATCH] Added createJSONfile fix --- src/autopilot-core/exportAssistant.js | 2 +- src/files.js | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/autopilot-core/exportAssistant.js b/src/autopilot-core/exportAssistant.js index 93613fe..a120401 100644 --- a/src/autopilot-core/exportAssistant.js +++ b/src/autopilot-core/exportAssistant.js @@ -146,7 +146,7 @@ const exportAssistant = async (assistantSid, twilioClient, recoverSchema = false } } - const filename = await files.createAssistantJSONFile(assistant.uniqueName, recoverSchema); + const filename = files.createAssistantJSONFile(assistant.uniqueName, recoverSchema); await files.writeAssistantJSONFile(sampleAssistant, filename, recoverSchema); diff --git a/src/files.js b/src/files.js index 66f790e..10988cb 100644 --- a/src/files.js +++ b/src/files.js @@ -28,24 +28,24 @@ module.exports = { } }, - createAssistantJSONFile : async (filename, recoverSchema = false) => { + createAssistantJSONFile : (filename, recoverSchema = false) => { if(recoverSchema){ if(checkDirectoryExists()){ - await fs.writeFileSync(path.join(twilioRecoverySchemaDir,`backup-${filename}.json`),prettyJSONStringify({})); + fs.writeFileSync(path.join(twilioRecoverySchemaDir,`backup-${filename}.json`),prettyJSONStringify({})); return `backup-${filename}.json`; } }else{ try{ if(fs.existsSync(path.join(process.cwd(),`${filename}.json`))){ filename = `${filename}-${Date.now()}.json`; - await fs.writeFileSync(path.join(process.cwd(),filename)); + fs.writeFileSync(path.join(process.cwd(),filename), ''); return filename; }else{ - await fs.writeFileSync(path.join(process.cwd(),`${filename}.json`),{}); + fs.writeFileSync(path.join(process.cwd(),`${filename}.json`), ''); return `${filename}.json`; } } catch (err){ - return err; + throw err; } } },