plugin contained npm command,not work

已回答

I am writing a plugin for the idea, the idea's function is executed npm command.

When I debug plugin , It works fine, but not work when use build jar.

 

 

 

source code:https://github.com/alanhg/view-package-versions

 

I have added dependencies ,and not work.

 

<depends>com.intellij.modules.platform</depends>
<depends>com.intellij.modules.lang</depends>
<depends>JavaScript</depends>

 

0

The following code work.

 

```

ArrayList<String> cmds = new ArrayList<>();
cmds.add("npm");
GeneralCommandLine generalCommandLine = new GeneralCommandLine(cmds);
general CommandLine.setCharset(Charset.forName("UTF-8"));
generalCommandLine.setWorkDirectory(project.getBasePath());
generalCommandLine.addParameters("view", name, "versions", "--json");
String commandLineOutputStr = ScriptRunnerUtil.getProcessOutput(generalCommandLine);
Gson converter = new Gson();
Type type = new TypeToken<List<String>>() {
}.getType();
List<String> result = converter.fromJson(commandLineOutputStr, type);

```

0

请先登录再写评论。