From 2f27f4ff66d51affc3ac329870f907d96ceb023f Mon Sep 17 00:00:00 2001 From: =D Date: Thu, 4 May 2017 14:18:21 +0200 Subject: [PATCH 1/2] 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) --- nvm.iss | 52 ++++++++++++++++++++++++++++++++-------------------- 1 file changed, 32 insertions(+), 20 deletions(-) diff --git a/nvm.iss b/nvm.iss index c0c46685..cc27c293 100644 --- a/nvm.iss +++ b/nvm.iss @@ -77,7 +77,7 @@ end; var nodeInUse: string; -function TakeControl(np: string; nv: string): string; +procedure TakeControl(np: string; nv: string); var path: string; begin @@ -147,21 +147,26 @@ begin Exec(ExpandConstant('{cmd}'), '/C node -v > "' + TmpResultFile + '"', '', SW_HIDE, ewWaitUntilTerminated, ResultCode); LoadStringFromFile(TmpResultFile, stdout); NodeVersion := Trim(Ansi2String(stdout)); - msg1 := MsgBox('Node '+NodeVersion+' is already installed. Do you want NVM to control this version?', mbConfirmation, MB_YESNO) = IDNO; - if msg1 then begin - 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; - if msg2 then begin - TakeControl(NodePath, NodeVersion); + if WizardSilent then begin + TakeControl(NodePath, NodeVersion); + end + else begin + msg1 := MsgBox('Node '+NodeVersion+' is already installed. Do you want NVM to control this version?', mbConfirmation, MB_YESNO) = IDNO; + if msg1 then begin + 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; + if msg2 then begin + TakeControl(NodePath, NodeVersion); + end; + if not msg2 then begin + DeleteFile(TmpResultFile); + WizardForm.Close; + end; end; - if not msg2 then begin - DeleteFile(TmpResultFile); - WizardForm.Close; + if not msg1 then + begin + TakeControl(NodePath, NodeVersion); end; end; - if not msg1 then - begin - TakeControl(NodePath, NodeVersion); - end; end; // Make sure the symlink directory doesn't exist @@ -172,13 +177,18 @@ begin RemoveDir(SymlinkPage.Values[0]); end; if not dir1 then begin - msg3 := MsgBox(SymlinkPage.Values[0]+' will be overwritten and all contents will be lost. Do you want to proceed?', mbConfirmation, MB_OKCANCEL) = IDOK; - if msg3 then begin + if WizardSilent then begin RemoveDir(SymlinkPage.Values[0]); - end; - if not msg3 then begin - //RaiseException('The symlink cannot be created due to a conflict with the existing directory at '+SymlinkPage.Values[0]); - WizardForm.Close; + end + else begin + msg3 := MsgBox(SymlinkPage.Values[0]+' will be overwritten and all contents will be lost. Do you want to proceed?', mbConfirmation, MB_OKCANCEL) = IDOK; + if msg3 then begin + RemoveDir(SymlinkPage.Values[0]); + end; + if not msg3 then begin + //RaiseException('The symlink cannot be created due to a conflict with the existing directory at '+SymlinkPage.Values[0]); + WizardForm.Close; + end; end; end; end; @@ -199,7 +209,9 @@ var path: string; nvm_symlink: string; begin - MsgBox('Removing NVM for Windows will remove the nvm command and all versions of node.js, including global npm modules.', mbInformation, MB_OK); + if not UninstallSilent then begin + MsgBox('Removing NVM for Windows will remove the nvm command and all versions of node.js, including global npm modules.', mbInformation, MB_OK); + end; // Remove the symlink RegQueryStringValue(HKEY_LOCAL_MACHINE, From 40d90632d3ca53892dbdcc765d23765bbfccfeb5 Mon Sep 17 00:00:00 2001 From: Zougi Date: Thu, 4 May 2017 14:42:53 +0200 Subject: [PATCH 2/2] 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) --- nvm.iss | 50 +++++++++++++++++++------------------------------- 1 file changed, 19 insertions(+), 31 deletions(-) diff --git a/nvm.iss b/nvm.iss index cc27c293..804c1647 100644 --- a/nvm.iss +++ b/nvm.iss @@ -147,25 +147,20 @@ begin Exec(ExpandConstant('{cmd}'), '/C node -v > "' + TmpResultFile + '"', '', SW_HIDE, ewWaitUntilTerminated, ResultCode); LoadStringFromFile(TmpResultFile, stdout); NodeVersion := Trim(Ansi2String(stdout)); - if WizardSilent then begin - TakeControl(NodePath, NodeVersion); - end - else begin - msg1 := MsgBox('Node '+NodeVersion+' is already installed. Do you want NVM to control this version?', mbConfirmation, MB_YESNO) = IDNO; - if msg1 then begin - 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; - if msg2 then begin - TakeControl(NodePath, NodeVersion); - end; - if not msg2 then begin - DeleteFile(TmpResultFile); - WizardForm.Close; - end; - end; - if not msg1 then - begin + msg1 := SuppressibleMsgBox('Node '+NodeVersion+' is already installed. Do you want NVM to control this version?', mbConfirmation, MB_YESNO, IDYES) = IDNO; + if msg1 then begin + 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; + if msg2 then begin TakeControl(NodePath, NodeVersion); end; + if not msg2 then begin + DeleteFile(TmpResultFile); + WizardForm.Close; + end; + end; + if not msg1 then + begin + TakeControl(NodePath, NodeVersion); end; end; @@ -177,18 +172,13 @@ begin RemoveDir(SymlinkPage.Values[0]); end; if not dir1 then begin - if WizardSilent then begin + msg3 := SuppressibleMsgBox(SymlinkPage.Values[0]+' will be overwritten and all contents will be lost. Do you want to proceed?', mbConfirmation, MB_OKCANCEL, IDOK) = IDOK; + if msg3 then begin RemoveDir(SymlinkPage.Values[0]); - end - else begin - msg3 := MsgBox(SymlinkPage.Values[0]+' will be overwritten and all contents will be lost. Do you want to proceed?', mbConfirmation, MB_OKCANCEL) = IDOK; - if msg3 then begin - RemoveDir(SymlinkPage.Values[0]); - end; - if not msg3 then begin - //RaiseException('The symlink cannot be created due to a conflict with the existing directory at '+SymlinkPage.Values[0]); - WizardForm.Close; - end; + end; + if not msg3 then begin + //RaiseException('The symlink cannot be created due to a conflict with the existing directory at '+SymlinkPage.Values[0]); + WizardForm.Close; end; end; end; @@ -209,9 +199,7 @@ var path: string; nvm_symlink: string; begin - if not UninstallSilent then begin - MsgBox('Removing NVM for Windows will remove the nvm command and all versions of node.js, including global npm modules.', mbInformation, MB_OK); - end; + SuppressibleMsgBox('Removing NVM for Windows will remove the nvm command and all versions of node.js, including global npm modules.', mbInformation, MB_OK, IDOK); // Remove the symlink RegQueryStringValue(HKEY_LOCAL_MACHINE,