Skip to content

Commit

Permalink
fix(core): create missing files/folder during ghost-sync (resolve #99…
Browse files Browse the repository at this point in the history
…6) (#1031)
  • Loading branch information
epaminond committed Oct 17, 2018
1 parent 23ec177 commit 8463aa2
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions packages/core/botpress/src/cli/ghost-sync.js
Expand Up @@ -29,10 +29,16 @@ const writeRevisions = async (revisionsFile, revisions) => {
})
}

const writeFile = folderPath => async ({ file, content, deleted }) => {
const filePath = path.join(folderPath, file)
const writeFile = rootFolderPath => async ({ file, content, deleted }) => {
const folderPath = path.join(rootFolderPath, ...file.split('/').slice(0, -1))
const filePath = path.join(rootFolderPath, file)

if (!deleted) {
try {
await fs.statAsync(folderPath)
} catch (e) {
await fs.mkdirAsync(folderPath, { recursive: true })
}
return fs.writeFileAsync(filePath, content)
}

Expand All @@ -48,6 +54,11 @@ const writeFile = folderPath => async ({ file, content, deleted }) => {

const updateFolder = projectLocation => async ({ files, revisions, binary }, folder) => {
const folderPath = path.join(projectLocation, folder)
try {
await fs.statAsync(folderPath)
} catch (e) {
await fs.mkdirAsync(folderPath, { recursive: true })
}
const revisionsFile = path.join(folderPath, REVISIONS_FILE_NAME)
await writeRevisions(revisionsFile, revisions)

Expand Down

0 comments on commit 8463aa2

Please sign in to comment.