Files
  • index.js
  • help.js
  • keyboard.js
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
var help = require('./help');
var keyboard  = require('./keyboard');

console.log('Welcome!\n\nThis is a simple application that manages NodeJS process data working with a basic built-in terminal menu that shows data based in keyboard input.\n\nPress [enter] to start the application...');

keyboard.onReadable(option => {
	switch (option) {
		case 'a': console.log('\narch:', process.arch, '\n'); break;
		case 'e': console.log('\nenv:', process.env, '\n'); break;
		case 'f': console.log('\nplatform:', process.platform, '\n'); break;
		case 'm': console.log('\nmemory usage:', process.memoryUsage(), '\n'); break;
		case 'p': console.log('\npid:', process.pid, '\n'); break;
		case 'u': console.log('\nprocess uptime:', process.uptime(), '\n'); break;
		case 't': console.log('\ntitle:', process.title, '\n'); break;
		case 'v': console.log('\nversions:', process.versions, '\n'); break;
		case 'q': process.exit(0);    // Exit the application
		default:  help.showOptions(); // Show menu again
	}
});

// Trigger the callback when the exit is called
process.on('exit', () => console.log('\nGoodbye, see ya!'));

// Handle error and prevent app crash
process.on('uncaughtExecption', () => console.log('\nOps, it is a mistake!'));
node v9.7.1 linux/amd64