madskristensen / NpmTaskRunner

Visual Studio extension
Other
88 stars 32 forks source link

Extension unusable when no scripts exist #31

Closed scottaddie closed 8 years ago

scottaddie commented 8 years ago

Installed product versions

The extension is unusable when no scripts are defined in package.json. By "unusable", I mean that the "package.json" node doesn't appear in Task Runner Explorer.

Steps to recreate

  1. Create a new ASP.NET app with a package.json file.
  2. The scripts property in package.json should either be empty or not present at all. In the case of an empty scripts property, something like this would reproduce the problem:
{
  "version": "1.0.0",
  "name": "asp.net",
  "private": true,
  "scripts": {}
}
  1. View the Output window's "Task Runner Explorer" section and notice the following error message:

Failed to run "C:\working_folder\WebApplication1\src\WebApplication1\package.json"...

In this example, "WebApplication1" was the name given to the ASP.NET project.

Current behavior

The current behavior is incorrect because the Defaults node of the extension is still useful without scripts.

Expected behavior

After the fix is in place, the Defaults node will appear with "install" as an option: packagejson

Also as part of my forthcoming fix, the restart node will appear only when one of the following scripts exists in package.json:

  1. prerestart
  2. prestop
  3. stop
  4. poststop
  5. restart
  6. prestart
  7. start
  8. poststart
  9. postrestart

It was also decided that most users will publish npm modules from outside of the IDE (e.g., from the command shell). Consequently, the publish node is being removed from Defaults as well.

scottaddie commented 8 years ago

This was fixed with commit https://github.com/madskristensen/NpmTaskRunner/commit/76622f0b82f99f8a79d398d07471a4b1fa3b5501

madskristensen commented 8 years ago

The Failed to run... issue will be fixed by TRX in a future release.

Is it really useful to show just the install task when there is a context-menu item in Solution Explorer to Restore Packages and saving package.json auto-installs?

scottaddie commented 8 years ago

It's debatable, and I could take either side. The target audience for this extension seems to be those who use more advanced features of npm (e.g., custom scripts & predefined tasks). With that in mind, it's reassuring and convenient to see an option such as "install" here. It's obvious that the option maps to the npm install command, and the extension serves as the launching point for common npm commands. Confusion sets in when I see "Restore Packages" in the context menu. I ask myself question such as: "Is that menu item rolling up multiple npm commands into a single click?" For example, what is it doing in addition to npm install, if anything?