sanketbajoria / ssh2-promise

ssh with promise/async await and typescript support
https://www.npmjs.com/package/ssh2-promise
MIT License
148 stars 24 forks source link

Why are dist files not .gitignored #43

Closed cinderblock closed 4 years ago

cinderblock commented 4 years ago

Why are dist files not .gitignored?

sanketbajoria commented 4 years ago

@cinderblock Actually i am publishing npm package through dist folder.

cinderblock commented 4 years ago

Yes, you should publish the dist folder on npm (and arguably not the src folder).

That doesn't explain why the dist folder is checked into the git repository. The general consensus is that generated files should not be in repositories.

sanketbajoria commented 4 years ago

@cinderblock Yes, i should publish npm package from dist folder. It will require to update the package.json. Will do in next release

cinderblock commented 4 years ago

It should just take two things:

  1. Add a prepare script that calls tsc (or npm run build) - Not strictly required but is very useful
  2. Add an .npmignore file or add a files field to package.json

For more details about why these steps are needed/helpful, I'll point you to my SO answer:

Problems with .gitignore

There is one issue with this option that gets many people. When preparing a dependency, Npm and Yarn will only keep the files that are listed in the files section of package.json.

One might see that files defaults to all files being included and think they're done. What is easily missed is that .npmignore mostly overrides the files directive and, if .npmignore does not exist, .gitignore is used instead.

So, if you have your built files listed in .gitignore like a sane person, don't list your built files in files, and don't use a .npmignore file, prepare will seem broken.

If you fix files to only include the built files or add an empty .npmignore, you're all set.

sanketbajoria commented 4 years ago

Done