Skip to content

Commit

Permalink
Switch to shell script instead of postinstall
Browse files Browse the repository at this point in the history
npm does not run postinstall on every package install
  • Loading branch information
karlhorky committed Feb 13, 2021
1 parent a623e61 commit 0c25a8e
Showing 1 changed file with 30 additions and 9 deletions.
39 changes: 30 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,26 +67,47 @@ Alternatively, you can use a TypeSync config file: `.typesyncrc` or a `"typesync

## Run TypeSync Automatically After Every Install

To run TypeSync and install packages automatically after every package install, use a `postinstall` script to your `package.json`:
To run TypeSync and install packages automatically after every package install, create a file called `install-with-types.sh` with the following content:

```json
{
"scripts": {
"postinstall": "typesync && npm install"
}
}
```sh
npm install $1
npx typesync
npm install
```

If you use `yarn`, use this instead:

```sh
yarn add $1
yarn typesync
yarn
```

Run this command to make the file executable:

```sh
chmod +x install-with-types.sh
```

Or, if you use `yarn`:
Add the following to `package.json`:

```json
{
"scripts": {
"postinstall": "typesync && yarn"
"i": "./install-with-types.sh"
}
}
```

Then install packages like this:

```bash
npm run i <pkg name>

# Or, with yarn:
yarn i <pkg name>
```

# Typings packages

TypeSync will add typings for packages that:
Expand Down

0 comments on commit 0c25a8e

Please sign in to comment.