aionix 1.0.4 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/bin/index.js +32 -3
  2. package/package.json +1 -1
package/bin/index.js CHANGED
@@ -2,7 +2,7 @@
2
2
  'use strict';
3
3
 
4
4
  const chalk = require('chalk');
5
- const path = require('path');
5
+ const net = require('net');
6
6
 
7
7
  console.log(chalk.cyan.bold(`
8
8
  +==============================+
@@ -11,6 +11,35 @@ console.log(chalk.cyan.bold(`
11
11
  +==============================+
12
12
  `));
13
13
 
14
- console.log(chalk.green('Starting server...'));
14
+ // Check which ports are in use
15
+ async function checkPort(port) {
16
+ return new Promise((resolve) => {
17
+ const server = net.createServer();
18
+ server.listen(port, () => {
19
+ server.close(() => resolve(false)); // free
20
+ });
21
+ server.on('error', () => resolve(true)); // in use
22
+ });
23
+ }
15
24
 
16
- require('../server/app');
25
+ async function showPortStatus() {
26
+ const ports = [3000, 3001, 3002, 3003, 3004];
27
+ console.log(chalk.yellow('\nšŸ“” Port Status:'));
28
+ for (const port of ports) {
29
+ const inUse = await checkPort(port);
30
+ if (inUse) {
31
+ console.log(chalk.red(` ā— ${port} — IN USE`));
32
+ } else {
33
+ console.log(chalk.green(` ā—‹ ${port} — free`));
34
+ }
35
+ }
36
+ console.log('');
37
+ }
38
+
39
+ async function main() {
40
+ await showPortStatus();
41
+ console.log(chalk.green('Starting server...'));
42
+ require('../server/app');
43
+ }
44
+
45
+ main();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aionix",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "Offline Developer Toolkit - Learning, Tools & Productivity",
5
5
  "main": "server/app.js",
6
6
  "bin": {