Skip to content
This repository has been archived by the owner on Jul 6, 2019. It is now read-only.

Commit

Permalink
fix(fallback): exec is no
Browse files Browse the repository at this point in the history
  • Loading branch information
zkat committed Jun 9, 2017
1 parent 6a41b7e commit 42c1d30
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 36 deletions.
6 changes: 4 additions & 2 deletions auto-fallback.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ command_not_found_${opts.isBash ? 'handle' : 'handler'}() {
fi
echo "$1 not found. Trying with npx..." >&2
if ! [[ $1 =~ @ ]]; then
exec npx --no-install "$@"
npx --no-install "$@"
else
npx "$@"
fi
exec npx "$@"
return $?
}`
}

Expand Down
35 changes: 1 addition & 34 deletions test/auto-fallback.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,38 +7,11 @@ test('not called with option', (t) =>
exec('node .', (err, stdout, stderr) => {
t.equal(err.code, 1)
t.notOk(stdout)
t.match(stderr, /--shell-auto-fallback/)
t.match(stderr, /--shell-auto-fallback/g)
t.end()
})
)

test('no-install: fish', t => {
exec('node . --no-install --shell-auto-fallback fish', (err, stdout, stderr) => {
if (err) { throw err }
t.match(stdout, /--no-install/i)
t.notOk(stderr)
t.end()
})
})

test('no-install: bash', t => {
exec('node . --no-install --shell-auto-fallback bash', (err, stdout, stderr) => {
if (err) { throw err }
t.match(stdout, /--no-install/i)
t.notOk(stderr)
t.end()
})
})

test('no-install: zsh', t => {
exec('node . --no-install --shell-auto-fallback zsh', (err, stdout, stderr) => {
if (err) { throw err }
t.match(stdout, /--no-install/i)
t.notOk(stderr)
t.end()
})
})

test('detect: SHELL ~= fish', (t) =>
exec('node . --shell-auto-fallback', {
env: {
Expand All @@ -47,7 +20,6 @@ test('detect: SHELL ~= fish', (t) =>
}, (err, stdout, stderr) => {
if (err) { throw err }
t.match(stdout, /function __fish_command_not_found/)
t.notMatch(stdout, /--no-install/i)
t.notOk(stderr)
t.end()
})
Expand All @@ -61,7 +33,6 @@ test('detect: SHELL ~= bash', (t) =>
}, (err, stdout, stderr) => {
if (err) { throw err }
t.match(stdout, /command_not_found_handle\(/)
t.notMatch(stdout, /--no-install/i)
t.notOk(stderr)
t.end()
})
Expand All @@ -75,7 +46,6 @@ test('detect: SHELL ~= zsh', (t) =>
}, (err, stdout, stderr) => {
if (err) { throw err }
t.match(stdout, /command_not_found_handler\(/)
t.notMatch(stdout, /--no-install/i)
t.notOk(stderr)
t.end()
})
Expand Down Expand Up @@ -109,7 +79,6 @@ test('given: fish', (t) =>
exec('node . --shell-auto-fallback fish', (err, stdout, stderr) => {
if (err) { throw err }
t.match(stdout, /function __fish_command_not_found/)
t.notMatch(stdout, /--no-install/i)
t.notOk(stderr)
t.end()
})
Expand All @@ -119,7 +88,6 @@ test('given: bash', (t) =>
exec('node . --shell-auto-fallback bash', (err, stdout, stderr) => {
if (err) { throw err }
t.match(stdout, /command_not_found_handle\(/)
t.notMatch(stdout, /--no-install/i)
t.notOk(stderr)
t.end()
})
Expand All @@ -129,7 +97,6 @@ test('given: zsh', (t) =>
exec('node . --shell-auto-fallback zsh', (err, stdout, stderr) => {
if (err) { throw err }
t.match(stdout, /command_not_found_handler\(/)
t.notMatch(stdout, /--no-install/i)
t.notOk(stderr)
t.end()
})
Expand Down

0 comments on commit 42c1d30

Please sign in to comment.