Skip to content

Commit

Permalink
fix: refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
test123456789012345 committed Jun 20, 2020
1 parent fcf877b commit 1e46dec
Showing 1 changed file with 23 additions and 17 deletions.
40 changes: 23 additions & 17 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,31 @@ import {
} from '@dword-design/functions'
import resolveFrom from 'resolve-from'

const getSegments = node => {
if (
node.callee?.object?.name === 'execa' &&
node.callee?.property?.name === 'command' &&
node.arguments[0].type === 'StringLiteral'
) {
return node.arguments[0].value |> split(' ')
}
if (node.callee?.name === 'execa') {
return [
...(node.arguments[0].type === 'StringLiteral'
? [node.arguments[0].value]
: []),
...(node.arguments[1]?.type === 'ArrayExpression'
? node.arguments[1].elements
|> filter({ type: 'StringLiteral' })
|> map('value')
: []),
]
}
return []
}
export default (node, deps) => {
if (node.type === 'CallExpression') {
const segments =
node.callee?.object?.name === 'execa' &&
node.callee?.property?.name === 'command' &&
node.arguments[0].type === 'StringLiteral'
? node.arguments[0].value |> split(' ')
: node.callee?.name === 'execa'
? [
...(node.arguments[0].type === 'StringLiteral'
? [node.arguments[0].value]
: []),
...(node.arguments[1]?.type === 'ArrayExpression'
? node.arguments[1].elements
|> filter({ type: 'StringLiteral' })
|> map('value')
: []),
]
: []
const segments = getSegments(node)
if (segments.length > 0) {
const binaryPackageMap =
deps
Expand Down

0 comments on commit 1e46dec

Please sign in to comment.