Code Monkey home page Code Monkey logo

osd600-release0.1's Introduction

OSD600-Release0.1

Description of Tool

  • This is a command line tool that takes a file as input, reads and finds http:// and https:// links throughout the file and tells the user which ones are working and which ones are broken. Example usage: node lab1.js test.html
  • The tool will output all of the links in different colours: red (broken), green (not broken) unknown (grey). You may also give the agrument v or version to check the current version of the tool. If the user enters no arguments a standard help/usage message showing how to run the tool, which command line arguments can be passed will be showen.

Commands Available

  • node index.js v and node index.js version will print the current version of the tool.
  • node index.js test.html (or a different file) Grabs all links and outputs them with a status code (colour coded).
  • node index.js test.html --good Outputs only the links with status code of 200 (green), can also use --bad option to only output the broken links with a status code of 404 (red).
  • node index.js --ignore ignore.txt test.txt Runs tool like normal but takes in another file with links to ignore, (dont process)
  • node index.js --telescope check links on latest 10 posts on local telescope instance (http://localhost:3000/posts)

installation

This node package is to be ran from the command line with npx. In a node project first install npx via npm (npm install npx). Then install this tool via npm (npm install jassal-link-checker). You can then run it like: npx jassal-link-checker test.txt

osd600-release0.1's People

Contributors

joey2031 avatar strawberries73 avatar humphd avatar zg3d avatar klee214 avatar

Watchers

James Cloos avatar  avatar

osd600-release0.1's Issues

Readme is not clear enough

In the "how to use" section of the readme, I suggest you add the exact commands/steps to run your program.

Something like this:

How to use

  • open terminal in the OSD600-Release0.1\BrokenLinkChecker- Release 0.1 directory
  • node lab1.js test.html (or a different file)

Version argument is bugged

When the user inputs "node lab1.js -v" or "--version", the app gives an error.

PS C:\Users\raymo\Documents\3yearseneca\OSD600\testingrepos\OSD600-Release0.1\BrokenLinkChecker- Release 0.1> node lab1.js -v
internal/fs/utils.js:269
    throw err;

Error: ENOENT: no such file or directory, open '-v'
    at Object.openSync (fs.js:462:3)
    at Object.readFileSync (fs.js:364:35)
    at Object.<anonymous> (C:\Users\raymo\Documents\3yearseneca\OSD600\testingrepos\OSD600-Release0.1\BrokenLinkChecker- Release 0.1\lab1.js:29:23)
    at Module._compile (internal/modules/cjs/loader.js:1137:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
    at Module.load (internal/modules/cjs/loader.js:985:32)
    at Function.Module._load (internal/modules/cjs/loader.js:878:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
    at internal/main/run_main_module.js:17:47 {
  errno: -4058,
  syscall: 'open',
  code: 'ENOENT',
  path: '-v'
}

I suggest changing the arguments checker to this:

if (process.argv[2] == **"-v"** || process.argv[2] == **"--version"**) {
        console.log(packageJson.name + " Version " + packageJson.version);
    }

from what it was originally

.then() not waiting for Promise function to resolve

On the issue-9 branch in index.js the function call to makeCalls is not waiting for it to resolve. MakCalls sets the value of allGood but for some reason, it's executing any code I put in the then() first.

        makeCalls().then(() => {
            console.log(allGood)
            console.log("Done");
        }).catch((err) => {
            console.log(err)
        });

Output:
image

Request to add ignore link feature

When running the tool with the --ignore flag you can pass in a txt file with a list of urls. These urls will be ignored in your program!

Support --all, --good, and --bad flags

--all will be the default flag (if they don't enter a flag), it will display every url.
--good only displays good url's (green)
--bad only displays bad ursl (red)

more unit test for `makeCalls`

Problem

So far, makeCalls is only tested if there is actual link whether it is valid or not. However, for some reasons (Connection fail, router problem...) undefined or null value can be passed instead of link.

We should hand this error either!

Suggestion

Create a one more unit test for this. Like
test("Pass array with undefined, empty array and null to makeCalls should return empty array", ...)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.