Skip to content

Commit

Permalink
chore(lint): use isexe module
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Oct 15, 2020
1 parent c31f185 commit 5817e81
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 23 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@
"inquirer": "^6.5.1",
"inquirer-autocomplete-prompt": "^1.0.1",
"is-docker": "^2.0.0",
"isexe": "^2.0.0",
"jwt-decode": "^3.0.0",
"lambda-local": "^1.7.1",
"lodash.debounce": "^4.0.8",
Expand Down
25 changes: 2 additions & 23 deletions src/lib/exec-fetcher.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
const path = require('path')
const execa = require('execa')
const { fetchLatest, updateAvailable } = require('gh-release-fetch')
const isExe = require('isexe')

const { NETLIFYDEVWARN } = require('../utils/logo')
const fs = require('./fs')

const isWindows = () => {
return process.platform === 'win32'
Expand All @@ -25,27 +25,6 @@ const getOptions = () => {
}
}

const isExe = (mode, gid, uid) => {
if (isWindows()) {
return true
}

const isGroup = gid ? process.getgid && gid === process.getgid() : true
const isUser = uid ? process.getuid && uid === process.getuid() : true

return Boolean(mode & 0o0001 || (mode & 0o0010 && isGroup) || (mode & 0o0100 && isUser))
}

const execExist = async (binPath) => {
try {
const stat = await fs.statAsync(binPath)
return stat.isFile() && isExe(stat.mode, stat.gid, stat.uid)
} catch (error) {
if (error.code === 'ENOENT') return false
throw error
}
}

const isVersionOutdated = async ({ packageName, currentVersion }) => {
const options = getOptions()
const outdated = await updateAvailable(getRepository({ packageName }), currentVersion, options)
Expand All @@ -55,7 +34,7 @@ const isVersionOutdated = async ({ packageName, currentVersion }) => {
const shouldFetchLatestVersion = async ({ binPath, packageName, execName, execArgs, pattern, log }) => {
const execPath = path.join(binPath, getExecName({ execName }))

const exists = await execExist(execPath)
const exists = await isExe(execPath, { ignoreErrors: true })
if (!exists) {
return true
}
Expand Down

0 comments on commit 5817e81

Please sign in to comment.