Skip to content

Commit

Permalink
fix: handle case when not running in a nodejs module dir (#284)
Browse files Browse the repository at this point in the history
  • Loading branch information
ricksbrown committed Oct 1, 2020
1 parent 6a72aa7 commit 0d3d11e
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/utils.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const la = require('lazy-ass')
const is = require('check-more-types')
const { join } = require('path')
const { existsSync } = require('fs')

/**
* Returns parsed command line arguments.
Expand Down Expand Up @@ -82,6 +83,9 @@ const isPackageScriptName = command => {
la(is.unemptyString(command), 'expected command name string', command)

const packageFilename = join(process.cwd(), 'package.json')
if (!existsSync(packageFilename)) {
return false
}
const packageJson = require(packageFilename)
if (!packageJson.scripts) {
return false
Expand Down

0 comments on commit 0d3d11e

Please sign in to comment.