win/msi: make 'add to path' a separate feature
authorBert Belder <bertbelder@gmail.com>
Thu, 7 Mar 2013 13:44:46 +0000 (14:44 +0100)
committerBert Belder <bertbelder@gmail.com>
Fri, 8 Mar 2013 17:00:37 +0000 (18:00 +0100)
tools/msvs/msi/product.wxs

index 2597c00..ba9a0ad 100755 (executable)
       </Feature>
     </Feature>
 
-    <Directory Id="TARGETDIR" Name="SourceDir">
+    <Feature Id="EnvironmentPath"
+             Level="1"
+             Title="Add to PATH"
+             Description="Add Node, NPM, and modules that were globally installed by NPM to the PATH environment variable.">
+      <Feature Id="EnvironmentPathNode"
+               Level="1"
+               Title="Node and NPM"
+               Description="Add Node and NPM (if installed) to the PATH environment variable.">
+        <ComponentRef Id="EnvironmentPathNode"/>
+      </Feature>
+
+      <Feature Id="EnvironmentPathNpmModules"
+               Level="1"
+               Title="NPM modules"
+               Description="Add modules that are installed globablly by NPM to the PATH environment variable. This option works for the current user only; other users need to update their PATH manually.">
+        <ComponentRef Id="EnvironmentPathNpmModules"/>
+      </Feature>
+    </Feature>
 
+    <Directory Id="TARGETDIR" Name="SourceDir">
       <Directory Id="ProgramMenuFolder">
           <Directory Id="ApplicationProgramsFolder" Name="Node.js ($(var.Platform))"/>
       </Directory>
         <Directory Id="INSTALLDIR" Name="nodejs">
           <Component Id="nodeexe" Guid="AEC0F08E-89B3-4C35-A286-8DB8598597F2">
             <File Id="filenodeexe" KeyPath="yes" Source="$(var.SourceDir)\node.exe" />
-            <Environment Id="npm_env"
-                         Action="set"
-                         Name="PATH"
-                         Part="last"
-                         System="no"
-                         Value="[AppDataFolder]npm\" />
-            <Environment Id="node_env"
-                         Action="set"
-                         Name="PATH"
-                         Part="last"
-                         System="yes"
-                         Value="[INSTALLDIR]" />
           </Component>
           <Component Id="nodejsvars" Guid="*">
             <File Id="filenodejsvars" KeyPath="yes" Source="$(var.RepoDir)\tools\msvs\nodejsvars.bat" />
       </Directory>
     </DirectoryRef>
 
+    <DirectoryRef Id="INSTALLDIR">
+      <Component Id="EnvironmentPathNode">
+        <RegistryValue Root="HKLM"
+                       Key="$(var.RegistryKeyPath)\Components"
+                       Name="EnvironmentPathNode"
+                       Type="integer"
+                       Value="1"
+                       KeyPath="yes"/>
+        <Environment Id="EnvironmentPathNode"
+                     Action="set"
+                     Name="PATH"
+                     Part="last"
+                     System="yes"
+                     Value="[INSTALLDIR]"/>
+      </Component>
+
+      <Component Id="EnvironmentPathNpmModules">
+        <RegistryValue Root="HKCU"
+                       Key="$(var.RegistryKeyPath)\Components"
+                       Name="EnvironmentPathNpmModules"
+                       Type="integer"
+                       Value="1"
+                       KeyPath="yes"/>
+        <Environment Id="EnvironmentPathNpmModules"
+                     Action="set"
+                     Name="PATH"
+                     Part="last"
+                     System="no"
+                     Value="[AppDataFolder]npm"/>
+      </Component>
+    </DirectoryRef>
+
     <DirectoryRef Id="ApplicationProgramsFolder">
       <Component Id="ApplicationShortcut" Guid="9b1ab94a-8f54-4f19-a5c4-b890de474162">
         <Shortcut Id="ApplicationStartMenuShortcut" Name="Node.js"