0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2025-01-27 22:59:51 -05:00

make path to local-db if it doesn't exist

This commit is contained in:
Alex Kocharin 2014-11-25 03:16:58 +03:00
parent 40baedaa78
commit feae33499e

View file

@ -1,4 +1,5 @@
var fs = require('fs') var fs = require('fs')
var Path = require('path')
module.exports = LocalData module.exports = LocalData
@ -35,6 +36,9 @@ LocalData.prototype.get = function() {
LocalData.prototype.sync = function() { LocalData.prototype.sync = function() {
// Uses sync to prevent ugly race condition // Uses sync to prevent ugly race condition
try {
require('mkdirp').sync(Path.dirname(this.path))
} catch(err) {}
fs.writeFileSync(this.path, JSON.stringify(this.data)) fs.writeFileSync(this.path, JSON.stringify(this.data))
} }