Skip to content

Commit

Permalink
Fix linting errors and update the package.json file.
Browse files Browse the repository at this point in the history
  • Loading branch information
F1LT3R committed Dec 29, 2019
1 parent 6c8aab3 commit b4cbf66
Show file tree
Hide file tree
Showing 16 changed files with 99 additions and 95 deletions.
4 changes: 3 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{
"xo.enable": true,
"xo.format.enable": true
}
}

6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
- Markserv uses [Semantic Versioning](http://semver.org/)
- Markserv [Keeps a ChangeLog](https://keepachangelog.com/en/1.0.0/)

## [1.17.4] - 2019-12-28

### Changed

- Update to latest packages using `npm-check-updates`. Update new linting errors from latest XO package. [#99]

## [1.17.3] - 2019-12-28

### Added
Expand Down
5 changes: 0 additions & 5 deletions lib/cli-defs.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,26 @@
module.exports = {
flags: {
port: {
type: 'number',
alias: 'p',
default: '8642'
},

livereloadport: {
type: ['number', 'boolean'],
alias: 'b',
default: 35729
},

address: {
type: 'string',
alias: 'a',
default: 'localhost'
},

silent: {
type: 'boolean',
alias: 's',
default: false
},

verbose: {
type: 'boolean',
alias: 'v',
default: false
}
Expand Down
2 changes: 1 addition & 1 deletion lib/misc/gen-icons-css.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ iconCSS.push(`.icon {

Reflect.ownKeys(materialIcons.iconDefinitions).forEach(iconName => {
const iconFile = materialIcons.iconDefinitions[iconName].iconPath
iconCSS.push(`.icon.${iconName}:before {
iconCSS.push(`.icon.${iconName}:before {
background: url("{markserv}icons/${iconFile}") no-repeat;
}
`)
Expand Down
3 changes: 2 additions & 1 deletion lib/readme.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ const fileExistsSync = uri => {
if (stat.isFile()) {
exists = true
}
} catch (err) {
} catch (error) {
console.warn(`${uri} does not exist`, error)
exists = false
}

Expand Down
74 changes: 37 additions & 37 deletions lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const path = require('path')
const fs = require('fs')

const chalk = require('chalk')
const opn = require('opn')
const opn = require('open')
const Promise = require('bluebird')
const connect = require('connect')
const less = require('less')
Expand Down Expand Up @@ -111,13 +111,12 @@ const log = (str, flags, err) => {
if (flags.silent) {
return
}

if (str) {
// eslint-disable-next-line no-console
console.log(str)
}

if (err) {
// eslint-disable-next-line no-console
console.error(err)
}
}
Expand Down Expand Up @@ -147,8 +146,8 @@ const markdownToHTML = markdownText => new Promise((resolve, reject) => {

try {
result = md.render(markdownText)
} catch (err) {
return reject(err)
} catch (error) {
return reject(error)
}

resolve(result)
Expand All @@ -160,6 +159,7 @@ const getFile = path => new Promise((resolve, reject) => {
if (err) {
return reject(err)
}

resolve(data)
})
})
Expand Down Expand Up @@ -221,8 +221,8 @@ const dirToHtml = filePath => {
prettyPath += '/'
}

if (prettyPath.substr(prettyPath.length - 2, 2) === '//') {
prettyPath = prettyPath.substr(0, prettyPath.length - 1)
if (prettyPath.slice(prettyPath.length - 2, 2) === '//') {
prettyPath = prettyPath.slice(0, prettyPath.length - 1)
}

urls.forEach(subPath => {
Expand Down Expand Up @@ -297,11 +297,12 @@ const createBreadcrumbs = path => {

// Http_request_handler: handles all the browser requests
const createRequestHandler = flags => {
let dir = flags.dir
let {dir} = flags
const isDir = fs.statSync(dir).isDirectory()
if (!isDir) {
dir = path.parse(flags.dir).dir
}

flags.$openLocation = path.relative(dir, flags.dir)

const implantOpts = {
Expand All @@ -325,8 +326,8 @@ const createRequestHandler = flags => {
msg('implant', style.link(absUrl), flags)
resolve(data)
})
.catch(err => {
warnmsg('implant 404', style.link(absUrl), flags, err)
.catch(error => {
warnmsg('implant 404', style.link(absUrl), flags, error)
resolve(false)
})
}),
Expand All @@ -338,8 +339,8 @@ const createRequestHandler = flags => {
msg('implant', style.link(absUrl), flags)
resolve(data)
})
.catch(err => {
warnmsg('implant 404', style.link(absUrl), flags, err)
.catch(error => {
warnmsg('implant 404', style.link(absUrl), flags, error)
resolve(false)
})
}),
Expand All @@ -351,8 +352,8 @@ const createRequestHandler = flags => {
msg('implant', style.link(absUrl), flags)
resolve(data)
})
.catch(err => {
warnmsg('implant 404', style.link(absUrl), flags, err)
.catch(error => {
warnmsg('implant 404', style.link(absUrl), flags, error)
resolve(false)
})
}),
Expand All @@ -364,8 +365,8 @@ const createRequestHandler = flags => {
msg('implant', style.link(absUrl), flags)
resolve(data)
})
.catch(err => {
warnmsg('implant 404', style.link(absUrl), flags, err)
.catch(error => {
warnmsg('implant 404', style.link(absUrl), flags, error)
resolve(false)
})
})
Expand Down Expand Up @@ -417,6 +418,7 @@ const createRequestHandler = flags => {
if (flags.verbose) {
msg('{markserv url}', style.link(markservRelFilePath), flags)
}

send(req, markservRelFilePath).pipe(res)
return
}
Expand All @@ -435,7 +437,7 @@ const createRequestHandler = flags => {
isMarkdown = isType(fileTypes.markdown, filePath)
isHtml = isType(fileTypes.html, filePath)
}
} catch (err) {
} catch (error) {
const fileName = path.parse(filePath).base
if (fileName === 'favicon.ico') {
res.writeHead(200, {'Content-Type': 'image/x-icon'})
Expand All @@ -444,8 +446,8 @@ const createRequestHandler = flags => {
return
}

errormsg('404', filePath, flags, err)
errorPage(404, filePath, err)
errormsg('404', filePath, flags, error)
errorPage(404, filePath, error)
return
}

Expand Down Expand Up @@ -475,9 +477,8 @@ const createRequestHandler = flags => {
})
})
})
}).catch(err => {
// eslint-disable-next-line no-console
console.error(err)
}).catch(error => {
console.error(error)
})
} else if (isHtml) {
msg('html', style.link(prettyPath), flags)
Expand All @@ -488,9 +489,8 @@ const createRequestHandler = flags => {
})
res.end(output)
})
}).catch(err => {
// eslint-disable-next-line no-console
console.error(err)
}).catch(error => {
console.error(error)
})
} else if (isDir) {
try {
Expand All @@ -515,13 +515,12 @@ const createRequestHandler = flags => {
'content-type': 'text/html'
})
res.end(output)
}).catch(err => {
// eslint-disable-next-line no-console
console.error(err)
}).catch(error => {
console.error(error)
})
})
} catch (err) {
errorPage(500, filePath, err)
} catch (error) {
errorPage(500, filePath, error)
}
} else {
// Other: Browser requests other MIME typed file (handled by 'send')
Expand Down Expand Up @@ -553,13 +552,13 @@ const startHTTPServer = (connectApp, port, flags) => {
}

const startLiveReloadServer = (liveReloadPort, flags) => {
let dir = flags.dir
let {dir} = flags
const isDir = fs.statSync(dir).isDirectory()
if (!isDir) {
dir = path.parse(flags.dir).dir
}

const exts = fileTypes.watch.map(type => type.substr(1))
const exts = fileTypes.watch.map(type => type.slice(1))
const exclusions = fileTypes.exclusions.map(exPath => {
return path.join(dir, exPath)
})
Expand Down Expand Up @@ -596,7 +595,7 @@ const checkForUpgrade = () => new Promise((resolve, reject) => {
}

analyzeDeps(packageJson).then(analysis => {
const latest = analysis.dependencies.markserv.latest
const {latest} = analysis.dependencies.markserv

switch (analysis.dependencies.markserv.status) {
case 'error':
Expand All @@ -612,9 +611,9 @@ const checkForUpgrade = () => new Promise((resolve, reject) => {
resolve(false)
break
}
}).catch(err => {
}).catch(error => {
console.log('err')
reject(err)
reject(error)
})
})

Expand All @@ -628,6 +627,7 @@ const doUpgrade = (newerVersion, flags) => {
if (code) {
return msg(chalk.bgRed('✨UPGRADE✨'), 'Markserv could not upgrade.', flags)
}

msg(chalk.bgRed('✨UPGRADE✨'), 'Upgrade finished!', flags)
})
}
Expand Down Expand Up @@ -660,8 +660,8 @@ const optionalUpgrade = async flags => {
}

logInstallNotes()
}).catch(err => {
console.error(err)
}).catch(error => {
console.error(error)
})
}

Expand Down
56 changes: 28 additions & 28 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,50 +70,50 @@
},
"dependencies": {
"analyze-deps": "^2.0.0",
"bluebird": "^3.4.7",
"chalk": "^2.4.0",
"commander": "^2.5.1",
"connect": "^3.6.5",
"connect-livereload": "^0.6.0",
"deepmerge": "^2.1.0",
"emoji-regex": "^6.5.1",
"handlebars": "^4.0.11",
"bluebird": "^3.7.2",
"chalk": "^3.0.0",
"commander": "^4.0.1",
"connect": "^3.7.0",
"connect-livereload": "^0.6.1",
"deepmerge": "^4.2.2",
"emoji-regex": "^8.0.0",
"handlebars": "^4.5.3",
"implant": "^2.0.3",
"is-online": "^7.0.0",
"less": "^3.8.1",
"is-online": "^8.2.1",
"less": "^3.10.3",
"livereload": "^0.8.2",
"markdown-it": "^8.4.1",
"markdown-it-anchor": "^5.0.2",
"markdown-it": "^10.0.0",
"markdown-it-anchor": "^5.2.5",
"markdown-it-emoji": "^1.4.0",
"markdown-it-highlightjs": "^3.0.0",
"markdown-it-include": "^1.0.0",
"markdown-it-include": "^1.1.0",
"markdown-it-mathjax": "^2.0.0",
"markdown-it-table-of-contents": "^0.4.3",
"markdown-it-table-of-contents": "^0.4.4",
"markdown-it-task-lists": "^2.1.1",
"meow": "^5.0.0",
"micromatch": "^3.1.3",
"mime": "^1.4.1",
"opn": "^5.3.0",
"meow": "^6.0.0",
"micromatch": "^4.0.2",
"mime": "^2.4.4",
"open": "^6.0.0",
"promptly": "^3.0.3",
"send": "^0.16.0",
"snyk": "^1.134.2",
"term-img": "^3.0.0"
"send": "^0.17.1",
"snyk": "^1.266.0",
"term-img": "^4.1.0"
},
"devDependencies": {
"all-contributors-cli": "^6.1.2",
"all-contributors-cli": "^6.11.2",
"ava": "^2.4.0",
"coveralls": "^3.0.0",
"get-port": "^3.2.0",
"husky": "^0.14.3",
"coveralls": "^3.0.9",
"get-port": "^5.1.0",
"husky": "^3.1.0",
"nyc": "^15.0.0",
"request": "^2.85.0",
"xo": "^0.20.3"
"request": "^2.88.0",
"xo": "^0.25.3"
},
"xo": {
"esnext": true,
"semicolon": false,
"rules": {
"node/no-unpublished-bin": false
"node/no-unpublished-bin": 2
}
},
"ava": {
Expand Down
Loading

0 comments on commit b4cbf66

Please sign in to comment.