diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c2658d7 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +node_modules/ diff --git a/README.md b/README.md index 468464f..d660568 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,6 @@ assignment_node_hello_world =========================== +By Brennan Fulmer -Just Node.js saying hello to the world and such. - - - - +In this assignment I learned the basics of Node and used Lodash and Chalk to display a series of error messages diff --git a/index.js b/index.js new file mode 100644 index 0000000..1ff6d9b --- /dev/null +++ b/index.js @@ -0,0 +1,21 @@ + +const chalk = require("chalk"); +var _ = require("lodash"); +var logger = require("./lib/logger"); +var record = require("./data/logs"); + +console.log("Hello World!"); +console.log(chalk.red("chalk")); +console.log(_.name); + +_.each([1, 2, 3], function(value) { + console.log(value); +}); + +logger.log("test", "info"); +logger.log("123", "warning"); +logger.log("abc", "error"); + +_.each(record, function(value) { + logger.log(value.message, value.level); +}); diff --git a/lib/logger.js b/lib/logger.js new file mode 100644 index 0000000..8b809ff --- /dev/null +++ b/lib/logger.js @@ -0,0 +1,28 @@ + +const chalk = require("chalk"); + +var logger = { + log: function(message, level) { + if (level == "info") { + this.info(message); + } else if (level == "warning") { + this.warning(message); + } else if (level == "error") { + this.error(message); + } + }, + + info: function(message) { + console.log(chalk.blue(message)); + }, + + warning: function(message) { + console.log(chalk.yellow(message)); + }, + + error: function(message) { + console.log(chalk.red(message)); + } +}; + +module.exports = logger; diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..a951dfd --- /dev/null +++ b/package-lock.json @@ -0,0 +1,62 @@ +{ + "name": "hello_world", + "version": "1.0.0", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "ansi-styles": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.0.tgz", + "integrity": "sha512-NnSOmMEYtVR2JVMIGTzynRkkaxtiq1xnFBcdQD/DnNCYPoEPsVJhM98BDyaoNOQIi7p4okdi3E27eN7GQbsUug==", + "requires": { + "color-convert": "1.9.1" + } + }, + "chalk": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.3.1.tgz", + "integrity": "sha512-QUU4ofkDoMIVO7hcx1iPTISs88wsO8jA92RQIm4JAwZvFGGAV2hSAA1NX7oVj2Ej2Q6NDTcRDjPTFrMCRZoJ6g==", + "requires": { + "ansi-styles": "3.2.0", + "escape-string-regexp": "1.0.5", + "supports-color": "5.2.0" + } + }, + "color-convert": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.1.tgz", + "integrity": "sha512-mjGanIiwQJskCC18rPR6OmrZ6fm2Lc7PeGFYwCmy5J34wC6F1PzdGL6xeMfmgicfYcNLGuVFA3WzXtIDCQSZxQ==", + "requires": { + "color-name": "1.1.3" + } + }, + "color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=" + }, + "escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=" + }, + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=" + }, + "lodash": { + "version": "4.17.5", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.5.tgz", + "integrity": "sha512-svL3uiZf1RwhH+cWrfZn3A4+U58wbP0tGVTLQPbjplZxZ8ROD9VLuNgsRniTlLe7OlSqR79RUehXgpBW/s0IQw==" + }, + "supports-color": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.2.0.tgz", + "integrity": "sha512-F39vS48la4YvTZUPVeTqsjsFNrvcMwrV3RLZINsmHo+7djCvuUzSIeXOnZ5hmjef4bajL1dNccN+tg5XAliO5Q==", + "requires": { + "has-flag": "3.0.0" + } + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..9d131b1 --- /dev/null +++ b/package.json @@ -0,0 +1,23 @@ +{ + "name": "hello_world", + "version": "1.0.0", + "description": "Node_Hello_World", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/BrennanFulmer/assignment_node_hello_world.git" + }, + "author": "", + "license": "ISC", + "bugs": { + "url": "https://github.com/BrennanFulmer/assignment_node_hello_world/issues" + }, + "homepage": "https://github.com/BrennanFulmer/assignment_node_hello_world#readme", + "dependencies": { + "chalk": "^2.3.1", + "lodash": "^4.17.5" + } +}