fix: move no longer crash for non-existant sub-directory dest

This commit is contained in:
NGPixel 2017-06-01 20:30:32 -04:00
parent 4632330d7c
commit 36a6bc0827
2 changed files with 45 additions and 42 deletions

View File

@ -5,7 +5,7 @@
const Git = require('git-wrapper2-promise')
const Promise = require('bluebird')
const path = require('path')
const fs = Promise.promisifyAll(require('fs'))
const fs = Promise.promisifyAll(require('fs-extra'))
const _ = require('lodash')
const URL = require('url')
@ -229,7 +229,9 @@ module.exports = {
let self = this
let gitFilePath = entryPath + '.md'
let gitNewFilePath = newEntryPath + '.md'
let destPathObj = path.parse(this.getRepoPath() + '/' + gitNewFilePath)
return fs.ensureDir(destPathObj.dir).then(() => {
return self._git.exec('mv', [gitFilePath, gitNewFilePath]).then((cProc) => {
let out = cProc.stdout.toString()
if (_.includes(out, 'fatal')) {
@ -238,6 +240,7 @@ module.exports = {
}
return true
})
})
},
/**

View File

@ -9,7 +9,7 @@ block rootNavRight
a.button.is-outlined(v-on:click='$store.dispatch("modalDiscardPage/open")')
i.icon-cross
span= t('nav.discard')
a.button(v-on:click='$root.$emit("editor-save")')
a.button(v-on:click='$root.$emit("editor/save")')
i.icon-check
span= t('nav.savedocument')