Skip to content
This repository has been archived by the owner on Apr 19, 2022. It is now read-only.

Commit

Permalink
Merge pull request #62 from p1ho/development
Browse files Browse the repository at this point in the history
Minor Update (11/9/2019)
  • Loading branch information
p1ho authored Nov 9, 2019
2 parents 796a3b8 + 8b976a6 commit 33f22ff
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 13 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
language: node_js
node_js:
- "8"
after_success:
- npm run coveralls
deploy:
provider: npm
email: $NPM_EMAIL
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,20 @@ This takes in a file accepting one of the following formats: `.json`/`.xml`/`.tx
$ site-validator [options] --url <url>
--path <path-to-file>
```
If it's more convenient, you can also put the url/path at the end.
If it's more convenient, you can also put the url/path at the end, but you have to prepend with `--url` or `--path`.

## Options
| Flag | Description |
| --- | --- |
| `--page` | This validates the URL passed in without crawling. |
| `--ff` | (Fail Fast) This flag will stop the checking at the first error.<br>(Note: does not work with `--output`) |
| `--verbose` | This flag will pretty-print out the errors/warnings.<br>Without it, it'll only say whether page validated. |
| `--quiet` | This flag will ignore warnings or informational messages. |
| `--local` | This expects the url to be a localhost url<br>(e.g. `localhost:80/index.html`) |
| `--local` | This expects the url to be a localhost url<br>(e.g. `http://localhost`), if the site is not served on port 80, you have to specify the port number (e.g. `http://localhost:3000`). localhost sites served over HTTPS is not currently supported. |
| `--cache <min>` | By default, the sitemap generated will be cached for 60 minutes. Use this flag to change how long you want to cache the sitemap for. |
| `--clear-cache` | `$ site-validator --clear-cache` clears all cached sitemaps.<br>If you want to refetch and recache sitemap for a url:<br>`$ site-validator <url> --cache <minutes> --clear-cache` |
| `--clear-cache` | `$ site-validator --clear-cache` clears all cached sitemaps.<br>If you want to refetch and recache sitemap for a url:<br>`$ site-validator <url> --clear-cache` |
| `--output <filename>` | Outputs a json file in the current directory.<br>Filename optional, defaults to [ISO format](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString) current time<br>**[Output Schema](#output-schema)** |
| `--view <filename>` | Prints report from output json file (without `.json`) to console.<br>`$ site-validator <filename> --view`<br>`$ site-validator --view <filename>`<br>both works.
| `--view <filename>` | Prints report from output json file (without `.json`) to console.<br>`$ site-validator <filename> --view`<br>`$ site-validator --view <filename>`<br>both works. |
| `--page` | This validates the URL passed in without crawling. |
| `--ff` | (Fail Fast) This flag will stop the checking at the first error.<br>(Note: does not work with `--output`) |

## Other Commands

Expand Down
8 changes: 5 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,11 @@ if (options.view !== false) {
}
}

if (options.path === undefined && options.clearCache) {
clearCache('sitemap')
exit('No path entered, exiting...')
if (options.path === undefined) {
if (options.clearCache) {
clearCache('sitemap')
}
exit('No path entered. \nIf path is not the 1st argument, you must prepend it with --url or --path.')
}

/*
Expand Down
10 changes: 7 additions & 3 deletions lib/get-urls.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,13 @@ module.exports = async (options) => {
} else {
data = await urlsFromCrawler(path, options.cacheTime, options.clearCache)
if (data.length === 0) {
console.log(yellow('No Urls Found, retrying with HTTP...'))
path = normalizer(options.path, { forceHttp: true })
data = await urlsFromCrawler(path, options.cacheTime, options.clearCache)
if (options.isLocal) {
data = []
} else {
console.log(yellow('No Urls Found, retrying with HTTP...'))
path = normalizer(options.path, { forceHttp: true })
data = await urlsFromCrawler(path, options.cacheTime, options.clearCache)
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "site-validator-cli",
"version": "1.3.1",
"version": "1.3.2",
"description": "A command line tool that takes a URL or a file, then uses html-validator (a wrapper for https://validator.w3.org/nu/) to validate each page.",
"main": "index.js",
"directories": {
Expand Down

0 comments on commit 33f22ff

Please sign in to comment.