Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates package.json to use prepare instead of postinstall #160

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tmr08c
Copy link

@tmr08c tmr08c commented Nov 21, 2020

The npm postinstall script runs both on local npm install as well as
after being installed as a dependency of someone else’s project. The
prepare script only runs on local npm install (and before publishing).
npm-scripts

vscode is a devDependency, not a dependency, so if someone tries to
install this package as a dependency of their own, the installation
fails because ./node_modules/vscode does not exist.

One example of where it may be useful to install the package directly
would be when using something like
andrewbranch/gatsby-remark-vscode
which uses VS Code syntax highlighting and themes to generate the syntax
highlighting in Gatsby sites.

The postinstall to prepare change is
suggested
by the author of the Gatsby plugin as a way to work with languates that
aren't supported by VS Code out-of-the-box.

This change seems to have works successfully in the past for other VS
Code extensions as well:

Testing

After making this change, I was able to add this package as a dependency of my Gatsby project
and successfully have the gatsby-remark-vscode plugin highlight Elixir syntax.

I also tested that the build script still worked:

› npm run build

> vscode-elixir@1.1.0 build /path/to/package
> vsce package

Executing prepublish script 'npm run vscode:prepublish'...

> vscode-elixir@1.1.0 vscode:prepublish /path/to/package
> tsc -p ./

Created: ./vscode-elixir/vscode-elixir-1.1.0.vsix

with this I was able to manually add the vsix file to VS Code to install the extension.

Are there any other suggestions or practices to best test this?

The npm `postinstall` script runs both on local npm install as well as
after being installed as a dependency of someone else’s project. The
`prepare` script only runs on local npm install (and before publishing).
[npm-scripts](https://docs.npmjs.com/cli/v6/using-npm/scripts)

`vscode` is a `devDependency`, not a `dependency`, so if someone tries to
install this package as a dependency of their own, the installation
fails because `./node_modules/vscode` does not exist.

One example of where it may be useful to install the package directly
would be when using something like
[andrewbranch/gatsby-remark-vscode](https://github.com/andrewbranch/gatsby-remark-vscode)
which uses VS Code syntax highlighting and themes to generate the syntax
highlighting in Gatsby sites.

The `postinstall` to `prepare` change is
[suggested](andrewbranch/gatsby-remark-vscode#129)
by the author of the Gatsby plugin as a way to work with languates that
aren't supported by VS Code out-of-the-box.

This change seems to have works successfully in the past for other VS
Code extensions as well:

* juanfranblanco/vscode-solidity#186
* styled-components/vscode-styled-components#203
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant