Skip to content

Commit

Permalink
fix: linting errors
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesgeorge007 committed Jul 3, 2019
1 parent 75a306d commit 808bcfc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
10 changes: 8 additions & 2 deletions start.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ function stop (error, warn) {
process.exit(1)
}
if (warn) {
console.log(warn)
console.log(warn)
}
process.exit()
}
Expand All @@ -95,7 +95,13 @@ function runFastify (args, cb) {
return module.exports.stop('', `${opts._[0]} doesn't exist within ${process.cwd()}`)
}

const file = require(filePath)
let file = null

try {
file = require(filePath)
} catch (e) {
return module.exports.stop(e)
}

if (file.length !== 3 && file.constructor.name === 'Function') {
return module.exports.stop(new Error('Plugin function should contain 3 arguments. Refer to ' +
Expand Down
12 changes: 6 additions & 6 deletions test/start.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,9 @@ test('should throw on file not found', t => {

const oldStop = start.stop
t.tearDown(() => { start.stop = oldStop })
start.stop = function (err, warn) {
// test case changes
t.ok(/.*not-found doesn't exist within/.test(warn), warn)
start.stop = function (err, warn) { // eslint-disable-line
// test case changes
t.ok(/.*not-found.js doesn't exist within/.test(warn), warn)
}

const argv = [ '-p', getPort(), './data/not-found.js' ]
Expand All @@ -161,8 +161,8 @@ test('should throw on package not found', t => {

const oldStop = start.stop
t.tearDown(() => { start.stop = oldStop })
start.stop = function (err) {
t.ok(/Cannot find module.*unknown-package/.test(err.message), err.message)
start.stop = function (err, warn) { // eslint-disable-line
t.ok(/Cannot find module 'unknown-package'/.test(err.message), err.message)
}

const argv = [ '-p', getPort(), './test/data/package-not-found.js' ]
Expand All @@ -174,7 +174,7 @@ test('should throw on parsing error', t => {

const oldStop = start.stop
t.tearDown(() => { start.stop = oldStop })
start.stop = function (err) {
start.stop = function (err, warn) { // eslint-disable-line
t.equal(err.constructor, SyntaxError)
}

Expand Down

0 comments on commit 808bcfc

Please sign in to comment.