Skip to content
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
43 changes: 2 additions & 41 deletions Nodejs/Product/Nodejs/NodejsToolsInstallPath.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,65 +17,26 @@
using System;
using System.IO;
using System.Reflection;
using Microsoft.Win32;

namespace Microsoft.NodejsTools {
public static class NodejsToolsInstallPath {
private static string GetFromAssembly(Assembly assembly, string filename) {
string path = Path.Combine(
Path.GetDirectoryName(assembly.Location),
filename
);
filename);
if (File.Exists(path)) {
return path;
}
return string.Empty;
}

private static string GetFromRegistry(string filename) {
const string ROOT_KEY = "Software\\Microsoft\\NodejsTools\\" + AssemblyVersionInfo.VSVersion;

string installDir = null;
using (var baseKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32))
using (var configKey = baseKey.OpenSubKey(ROOT_KEY)) {
if (configKey != null) {
installDir = configKey.GetValue("InstallDir") as string;
}
}

if (string.IsNullOrEmpty(installDir)) {
using (var baseKey = RegistryKey.OpenBaseKey(RegistryHive.CurrentUser, RegistryView.Registry32))
using (var configKey = baseKey.OpenSubKey(ROOT_KEY)) {
if (configKey != null) {
installDir = configKey.GetValue("InstallDir") as string;
}
}
}

if (!String.IsNullOrEmpty(installDir)) {
var path = Path.Combine(installDir, filename);
if (File.Exists(path)) {
return path;
}
}

return string.Empty;
}

public static string GetFile(string filename) {
string path = GetFromAssembly(typeof(NodejsToolsInstallPath).Assembly, filename);
if (!string.IsNullOrEmpty(path)) {
return path;
}

path = GetFromRegistry(filename);
if (!string.IsNullOrEmpty(path)) {
return path;
}

throw new InvalidOperationException(
"Unable to determine Node.js Tools installation path"
);
throw new InvalidOperationException("Unable to determine Node.js Tools installation path");
}
}
}
4 changes: 2 additions & 2 deletions Nodejs/Product/Nodejs/Project/NodejsProjectNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1173,8 +1173,8 @@ protected override int ExecCommandThatDependsOnSelectedNodes(Guid cmdGroup, uint
);
handled = true;
return VSConstants.S_OK;
case PkgCmdId.cmdidAddNewJavaScriptFileCommand:

case PkgCmdId.cmdidAddNewJavaScriptFileCommand:
NewFileMenuGroup.NewFileUtilities.CreateNewJavaScriptFile(projectNode: this, containerId: selectedNodes[0].ID);
handled = true;
return VSConstants.S_OK;
Expand Down