mirror of
https://github.com/typicode/json-server.git
synced 2025-07-29 21:23:41 +08:00
Add --snapshots and basic test
This commit is contained in:
@ -32,6 +32,11 @@ module.exports = function () {
|
||||
alias: 's',
|
||||
description: 'Set static files directory'
|
||||
},
|
||||
snapshots: {
|
||||
alias: 'S',
|
||||
description: 'Set snapshots directory',
|
||||
default: '.'
|
||||
},
|
||||
delay: {
|
||||
alias: 'd',
|
||||
description: 'Add delay to responses (ms)'
|
||||
|
@ -117,7 +117,8 @@ module.exports = function (argv) {
|
||||
process.stdin.setEncoding('utf8')
|
||||
process.stdin.on('data', function (chunk) {
|
||||
if (chunk.trim().toLowerCase() === 's') {
|
||||
var file = 'db-' + Date.now() + '.json'
|
||||
var filename = 'db-' + Date.now() + '.json'
|
||||
var file = path.join(argv.snapshots, filename)
|
||||
app.db.saveSync(file)
|
||||
console.log(' Saved snapshot to ' + file + '\n')
|
||||
}
|
||||
|
Reference in New Issue
Block a user