From 911f6e4c29f971cc7f1cecc070f3fdcd5fbb97f7 Mon Sep 17 00:00:00 2001 From: Hammy Date: Sat, 26 Jun 2021 04:15:59 +0100 Subject: [PATCH] Upload code from "Getting Started With Node" module --- 3-getting-started/3-process/1-custom-env-variables.js | 6 ++++++ 3-getting-started/3-process/2-stdio-streams.js | 6 ++++++ 3-getting-started/3-process/3-process-exit.js | 7 +++++++ 3 files changed, 19 insertions(+) create mode 100644 3-getting-started/3-process/1-custom-env-variables.js create mode 100644 3-getting-started/3-process/2-stdio-streams.js create mode 100644 3-getting-started/3-process/3-process-exit.js diff --git a/3-getting-started/3-process/1-custom-env-variables.js b/3-getting-started/3-process/1-custom-env-variables.js new file mode 100644 index 0000000..3cdd83a --- /dev/null +++ b/3-getting-started/3-process/1-custom-env-variables.js @@ -0,0 +1,6 @@ +console.log('Current user is', process.env.USER); + +console.log('\nScript executed with:'); + +console.log('VAL1 equal to:', process.env.VAL1); +console.log('VAL2 equal to:', process.env.VAL2); diff --git a/3-getting-started/3-process/2-stdio-streams.js b/3-getting-started/3-process/2-stdio-streams.js new file mode 100644 index 0000000..fae226a --- /dev/null +++ b/3-getting-started/3-process/2-stdio-streams.js @@ -0,0 +1,6 @@ +process.stdin.on('readable', () => { + const chunk = process.stdin.read(); + if (chunk !== null) { + process.stdout.write(chunk); + } +}); diff --git a/3-getting-started/3-process/3-process-exit.js b/3-getting-started/3-process/3-process-exit.js new file mode 100644 index 0000000..1996c44 --- /dev/null +++ b/3-getting-started/3-process/3-process-exit.js @@ -0,0 +1,7 @@ +setTimeout(() => process.exit(), 2000); + +process.on('exit', () => { + console.log('Process will exit now. See you later!'); +}); + +console.log('Hello!');