plugin contained npm command,not work

Answered

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>

 

1 comment
Comment actions Permalink

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

Please sign in to leave a comment.