Skip to content

Commit

Permalink
fix: create reference folder
Browse files Browse the repository at this point in the history
if reference folder doesn't exit when creating first json from reference editor, this folder should be created
  • Loading branch information
wonknu committed May 18, 2017
1 parent 04711cf commit 2edaf31
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/cli/cms/reference/reference.js
Expand Up @@ -24,7 +24,16 @@ export function getFiles(name = '') {
}

export function saveFile(url, json) {
fse.writeJson(path.join(config.root, config.reference.url, url), JSON.parse(json), function (err) {
if(err) console.log('saveFile reference error: ', err)
fse.exists(path.join(config.root, config.reference.url), function (exists) {
if(!exists){
fse.mkdir(path.join(config.root, config.reference.url), function () {
fse.writeJson(path.join(config.root, config.reference.url, url), JSON.parse(json))
})
}
else{
fse.writeJson(path.join(config.root, config.reference.url, url), JSON.parse(json), function (err) {
if(err) console.log('saveFile reference error: ', err)
})
}
})
}

0 comments on commit 2edaf31

Please sign in to comment.