Skip to content

Commit 5c58754

Browse files
committed
Added project files from 3 different libraries for making a terminal UI, How to Compile your Node.js Application into an Executable Using Nexe for Windows, Linux, and OS X, How to Get The MIME Type of a File in JavaScript
1 parent be51ced commit 5c58754

8 files changed

Lines changed: 107 additions & 0 deletions

File tree

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// Import dependencies - https://www.npmjs.com/package/ora
2+
const ora = require("ora");
3+
4+
const spinner = ora("Loading unicorns").start();
5+
spinner.color = "green"; // "black" | "red" | "green" | "yellow" | "blue" | "magenta" | "cyan" | "white" | "gray"
6+
7+
setTimeout(() => {
8+
spinner.succeed();
9+
}, 1000);
10+
11+
12+
13+
// Import dependencies - https://www.npmjs.com/package/boxen
14+
const boxen = require("boxen");
15+
16+
console.log(boxen("unicorn", { padding: 1 }));
17+
console.log(boxen("unicorn", { padding: 1, margin: 1, borderStyle: "double" }));
18+
19+
20+
21+
// Import dependencies - https://www.npmjs.com/package/easy-table
22+
const Table = require("easy-table");
23+
24+
const products = [
25+
{ id: 123123, desc: "Something awesome", price: 1000.00 },
26+
{ id: 245452, desc: "Very interesting book", price: 11.45 },
27+
{ id: 232323, desc: "Yet another product", price: 555.55 }
28+
]
29+
30+
const table = new Table();
31+
32+
for (const product of products) {
33+
table.cell("Product Id", product.id);
34+
table.cell("Description", product.desc);
35+
table.cell("Price, USD", product.price, Table.number(2));
36+
table.newRow();
37+
}
38+
39+
console.log(table.toString());
40+
console.log(table.printTransposed());
41+
console.log(table.print());
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"name": "making-a-terminal-ui",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "index.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1"
8+
},
9+
"keywords": [],
10+
"author": "",
11+
"license": "MIT",
12+
"dependencies": {
13+
"boxen": "^4.2.0",
14+
"easy-table": "^1.1.1",
15+
"ora": "^4.0.4"
16+
}
17+
}

‎How to Compile your Node.js Application into an Executable Using Nexe for Windows, Linux, and OS X/config.json‎

Whitespace-only changes.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "express-app",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "index.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1"
8+
},
9+
"keywords": [],
10+
"author": "",
11+
"license": "MIT",
12+
"dependencies": {
13+
"express": "^4.16.3"
14+
}
15+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<h1>Hello World!</h1>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// Import dependencies
2+
const express = require("express");
3+
const path = require("path");
4+
const app = express();
5+
app.use("/", express.static(path.join(__dirname, "public")));
6+
7+
app.listen(80);
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Import dependencies
2+
const mime = require("mime");
3+
4+
console.log(mime.getType("txt")); // ⇨ "text/plain"
5+
console.log(mime.getType("test.txt")); // ⇨ "text/plain"
6+
console.log(mime.getType("F:vincentlab\\videos\\test.txt")); // ⇨ "text/plain"
7+
8+
console.log(mime.getExtension("text/plain")); // ⇨ "txt"
9+
10+
mime.define({"text/test": ["test", "tt"]});
11+
console.log(mime.getType("test")); // ⇨ "text/test"
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "how-to-get-the-mime-type-of-a-file-in-javascript",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "app.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1"
8+
},
9+
"keywords": [],
10+
"author": "",
11+
"license": "MIT",
12+
"dependencies": {
13+
"mime": "^2.4.4"
14+
}
15+
}

0 commit comments

Comments
 (0)