Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/autopilot-core/exportAssistant.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
10 changes: 5 additions & 5 deletions src/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
},
Expand Down