Skip to content

Commit cd1fd76

Browse files
author
Paul van Brenk
committed
Fix NPM commands when project is loaded
1 parent b7b0a11 commit cd1fd76

File tree

3 files changed

+237
-204
lines changed

3 files changed

+237
-204
lines changed

Nodejs/Product/Nodejs/Repl/NpmReplCommand.cs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,17 @@ public async Task<ExecutionResult> Execute(IReplWindow window, string arguments)
111111
}
112112

113113
Tuple<string, IVsHierarchy> projectInfo;
114-
NodejsProjectNode nodejsProject = null;
115114
if (string.IsNullOrEmpty(projectPath) && projectNameToDirectoryDictionary.Count == 1)
116115
{
117116
projectInfo = projectNameToDirectoryDictionary.Values.First();
118117
}
119-
else if (projectNameToDirectoryDictionary.TryGetValue(projectPath, out projectInfo))
118+
else
119+
{
120+
projectNameToDirectoryDictionary.TryGetValue(projectPath, out projectInfo);
121+
}
122+
123+
NodejsProjectNode nodejsProject = null;
124+
if (projectInfo != null)
120125
{
121126
projectPath = projectInfo.Item1;
122127
if (projectInfo.Item2 != null)
@@ -138,7 +143,7 @@ public async Task<ExecutionResult> Execute(IReplWindow window, string arguments)
138143

139144
if (!isGlobalCommand && !Directory.Exists(projectDirectoryPath))
140145
{
141-
window.WriteError("Please specify a valid Node.js project or project directory. If your solution contains multiple projects, specify a target project using .npm [ProjectName or ProjectDir] <npm arguments> For example: .npm [MyApp] list");
146+
window.WriteError(Resources.NpmSpecifyValidProject);
142147
return ExecutionResult.Failure;
143148
}
144149

@@ -183,9 +188,12 @@ await ExecuteNpmCommandAsync(
183188
return ExecutionResult.Success;
184189
}
185190

186-
public string Description => "Executes npm command. If solution contains multiple projects, specify target project using .npm [ProjectName] <npm arguments>";
191+
public string Description => Resources.NpmExecuteCommand;
192+
187193
public string Command => "npm";
194+
188195
public object ButtonContent => null;
196+
189197
// TODO: This is duplicated from Npm project
190198
// We should consider using InternalsVisibleTo to avoid code duplication
191199
internal static async Task<IEnumerable<string>> ExecuteNpmCommandAsync(
@@ -271,7 +279,8 @@ public NpmReplRedirector(IReplWindow window)
271279
this._window = window;
272280
this.HasErrors = false;
273281
}
274-
public bool HasErrors { get; set; }
282+
283+
public bool HasErrors { get; private set; }
275284

276285
public override void WriteLine(string decodedString)
277286
{

0 commit comments

Comments
 (0)