Skip to content

Commit 40d9063

Browse files
fredericrousFrederic ROUSSEAU
authored and
Frederic ROUSSEAU
committed
silent setup
- silent install without prompt as it's expected when we install nvm-windows from a script - silent uninstall - fix a warning (Warning: Line 80, Column 10: [Hint] Variable 'Result' never used)
1 parent 2f27f4f commit 40d9063

File tree

1 file changed

+19
-31
lines changed

1 file changed

+19
-31
lines changed

nvm.iss

Lines changed: 19 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -147,25 +147,20 @@ begin
147147
Exec(ExpandConstant('{cmd}'), '/C node -v > "' + TmpResultFile + '"', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
148148
LoadStringFromFile(TmpResultFile, stdout);
149149
NodeVersion := Trim(Ansi2String(stdout));
150-
if WizardSilent then begin
151-
TakeControl(NodePath, NodeVersion);
152-
end
153-
else begin
154-
msg1 := MsgBox('Node '+NodeVersion+' is already installed. Do you want NVM to control this version?', mbConfirmation, MB_YESNO) = IDNO;
155-
if msg1 then begin
156-
msg2 := MsgBox('NVM cannot run in parallel with an existing Node.js installation. Node.js must be uninstalled before NVM can be installed, or you must allow NVM to control the existing installation. Do you want NVM to control node '+NodeVersion+'?', mbConfirmation, MB_YESNO) = IDYES;
157-
if msg2 then begin
158-
TakeControl(NodePath, NodeVersion);
159-
end;
160-
if not msg2 then begin
161-
DeleteFile(TmpResultFile);
162-
WizardForm.Close;
163-
end;
164-
end;
165-
if not msg1 then
166-
begin
150+
msg1 := SuppressibleMsgBox('Node '+NodeVersion+' is already installed. Do you want NVM to control this version?', mbConfirmation, MB_YESNO, IDYES) = IDNO;
151+
if msg1 then begin
152+
msg2 := SuppressibleMsgBox('NVM cannot run in parallel with an existing Node.js installation. Node.js must be uninstalled before NVM can be installed, or you must allow NVM to control the existing installation. Do you want NVM to control node '+NodeVersion+'?', mbConfirmation, MB_YESNO, IDYES) = IDYES;
153+
if msg2 then begin
167154
TakeControl(NodePath, NodeVersion);
168155
end;
156+
if not msg2 then begin
157+
DeleteFile(TmpResultFile);
158+
WizardForm.Close;
159+
end;
160+
end;
161+
if not msg1 then
162+
begin
163+
TakeControl(NodePath, NodeVersion);
169164
end;
170165
end;
171166
@@ -177,18 +172,13 @@ begin
177172
RemoveDir(SymlinkPage.Values[0]);
178173
end;
179174
if not dir1 then begin
180-
if WizardSilent then begin
175+
msg3 := SuppressibleMsgBox(SymlinkPage.Values[0]+' will be overwritten and all contents will be lost. Do you want to proceed?', mbConfirmation, MB_OKCANCEL, IDOK) = IDOK;
176+
if msg3 then begin
181177
RemoveDir(SymlinkPage.Values[0]);
182-
end
183-
else begin
184-
msg3 := MsgBox(SymlinkPage.Values[0]+' will be overwritten and all contents will be lost. Do you want to proceed?', mbConfirmation, MB_OKCANCEL) = IDOK;
185-
if msg3 then begin
186-
RemoveDir(SymlinkPage.Values[0]);
187-
end;
188-
if not msg3 then begin
189-
//RaiseException('The symlink cannot be created due to a conflict with the existing directory at '+SymlinkPage.Values[0]);
190-
WizardForm.Close;
191-
end;
178+
end;
179+
if not msg3 then begin
180+
//RaiseException('The symlink cannot be created due to a conflict with the existing directory at '+SymlinkPage.Values[0]);
181+
WizardForm.Close;
192182
end;
193183
end;
194184
end;
@@ -209,9 +199,7 @@ var
209199
path: string;
210200
nvm_symlink: string;
211201
begin
212-
if not UninstallSilent then begin
213-
MsgBox('Removing NVM for Windows will remove the nvm command and all versions of node.js, including global npm modules.', mbInformation, MB_OK);
214-
end;
202+
SuppressibleMsgBox('Removing NVM for Windows will remove the nvm command and all versions of node.js, including global npm modules.', mbInformation, MB_OK, IDOK);
215203
216204
// Remove the symlink
217205
RegQueryStringValue(HKEY_LOCAL_MACHINE,

0 commit comments

Comments
 (0)