diff --git a/CHANGELOG.md b/CHANGELOG.md index 084e3c1..972166d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## [0.8.17][2016-07-25] + +* Fix snapshot creation for JS files (ex: `json-server generator.js`) + ## [0.8.16][2016-07-11] * Support `x-www-form-urlencoded` diff --git a/src/cli/run.js b/src/cli/run.js index 9e3d386..1369226 100644 --- a/src/cli/run.js +++ b/src/cli/run.js @@ -134,12 +134,9 @@ module.exports = function (argv) { if (chunk.trim().toLowerCase() === 's') { var filename = 'db-' + Date.now() + '.json' var file = path.join(argv.snapshots, filename) - app - .db - .write(file) - .then(function () { - console.log(' Saved snapshot to ' + path.relative(process.cwd(), file) + '\n') - }) + var state = app.db.getState() + fs.writeFileSync(file, JSON.stringify(state, null, 2), 'utf-8') + console.log(' Saved snapshot to ' + path.relative(process.cwd(), file) + '\n') } })