mirror of
https://github.com/typicode/json-server.git
synced 2025-07-28 04:32:24 +08:00
reacting to user entered 's' but only for json file
This commit is contained in:
11
bin/cli.js
11
bin/cli.js
@ -13,6 +13,15 @@ function loadFile(file, cb) {
|
||||
if (/\.js$/.test(file)) db = require(path).run();
|
||||
|
||||
cb(db);
|
||||
|
||||
process.stdin.resume();
|
||||
process.stdin.setEncoding('utf8');
|
||||
process.stdin.on('data', function (userInput) {
|
||||
console.log(userInput);
|
||||
if (userInput.trim().toLowerCase() == 's') {
|
||||
console.log('saving db');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function loadURL(url, cb) {
|
||||
@ -43,4 +52,4 @@ program
|
||||
if (program.port) options.port = program.port;
|
||||
if (program.readOnly) options.readOnly = true;
|
||||
if (program.file) loadFile(program.file, onDatabaseLoaded);
|
||||
if (program.url) loadURL(program.url, onDatabaseLoaded);
|
||||
if (program.url) loadURL(program.url, onDatabaseLoaded);
|
||||
|
Reference in New Issue
Block a user