Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[yarn] Suggest installed executables for yarn run #75

Merged
merged 1 commit into from
Dec 19, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion modules/matchers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ exports.create_files_matcher = function (file_pattern)
return function (token)
return w(clink.find_files(file_pattern))
:filter(function(file)
return clink.is_match(token, file)
-- Filter out '.' and '..' entries as well
return clink.is_match(token, file) and path.is_real_dir(file)
end )
end
end
Expand Down
7 changes: 4 additions & 3 deletions yarn.lua
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ local function global_modules(token)
return global_modules_matcher(token)
end

-- A function that matches all files in bin folder. See #74 for rationale
local bins = matchers.create_files_matcher('node_modules/.bin/*.')

-- Reads package.json in current directory and extracts all "script" commands defined
local function scripts(token) -- luacheck: no unused args

Expand Down Expand Up @@ -77,8 +80,6 @@ local add_parser = parser(
"--tilde", "-T"
)

local script_parser = parser({scripts})

local yarn_parser = parser({
"add"..add_parser,
"bin",
Expand Down Expand Up @@ -123,7 +124,7 @@ local yarn_parser = parser({
"--tag"
),
"remove"..parser({modules}),
"run"..script_parser,
"run"..parser({bins, scripts}),
"self-update",
"tag"..parser({"add", "ls", "rm"}),
"team"..parser({"add", "create", "destroy", "ls", "rm"}),
Expand Down