Skip to content

Commit dd8d7f7

Browse files
fix: update how args are passed to Plenary job
1 parent 880c0c4 commit dd8d7f7

File tree

2 files changed

+26
-17
lines changed

2 files changed

+26
-17
lines changed

lua/salesforce/component_generator.lua

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ local M = {}
55

66
local category = "Component generation"
77

8-
local executable = Util.get_sf_executable()
98
local prompt_for_name_and_dir = function(name_prompt, directory_prompt)
109
local lwc_name = vim.fn.input(name_prompt)
1110
local directory = vim.fn.input(directory_prompt, vim.fn.expand("%:p:h"), "dir")
@@ -38,7 +37,10 @@ local component_creation_callback = function(job)
3837

3938
if sfdx_response.status == 0 then
4039
Util.clear_and_notify(
41-
string.format("Successfully created in dir: %s", sfdx_response.result.outputDir)
40+
string.format(
41+
"Successfully created component in directory: %s",
42+
sfdx_response.result.outputDir
43+
)
4244
)
4345
else
4446
Util.clear_and_notify(
@@ -74,16 +76,21 @@ M.create_lightning_component = function()
7476
else
7577
type = "lwc"
7678
end
77-
local command = string.format(
78-
"%s lightning generate component --name %s --type %s --output-dir %s --json",
79-
executable,
79+
local args = {
80+
"lightning",
81+
"generate",
82+
"component",
83+
"--name",
8084
name,
85+
"--type",
8186
type,
82-
dir
83-
)
87+
"--output-dir",
88+
dir,
89+
"--json",
90+
}
8491
Util.clear_and_notify("Creating component...")
8592
Util.send_cli_command(
86-
command,
93+
args,
8794
component_creation_callback,
8895
category,
8996
"component_generator.lua"
@@ -117,16 +124,19 @@ M.create_apex = function()
117124
else
118125
type = "trigger"
119126
end
120-
local command = string.format(
121-
"%s apex generate %s --name %s --output-dir %s --json",
122-
executable,
127+
local args = {
128+
"apex",
129+
"generate",
123130
type,
131+
"--name",
124132
name,
125-
dir
126-
)
133+
"--output-dir",
134+
dir,
135+
"--json",
136+
}
127137
Util.clear_and_notify("Creating component...")
128138
Util.send_cli_command(
129-
command,
139+
args,
130140
component_creation_callback,
131141
category,
132142
"component_generator.lua"

lua/salesforce/util.lua

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,9 @@ function M.salesforce_cli_available()
127127
return false
128128
end
129129

130-
M.send_cli_command = function(command, on_exit_callback, category, caller_name)
130+
M.send_cli_command = function(args, on_exit_callback, category, caller_name)
131+
local command = table.concat(args, " ")
131132
Debug:log(caller_name, "Executing command %s", command)
132-
local args = M.split(command, " ")
133-
table.remove(args, 1)
134133
local new_job = Job:new({
135134
command = M.get_sf_executable(),
136135
env = M.get_env(),

0 commit comments

Comments
 (0)