I want to automatically copy certain files from an npm package to user's local directory after running
npm install my-package
I can get them installed by declaring "files" inside package.json. The problem is --- the files are not put in the local directory. So I need to run postinstall script.
But now I don't know where the package is installed (maybe higher up the directory tree), so how can I reliably access the files and copy them to the local directory via the script?
(By local directory I mean --- from where I run npm install my-package as user consuming the package.)
UPDATE. It seems the postinstall script runs as npm owned process with home directory being node_modules/my-package, so I still don't know how to access user's home directory other than with naive ../../.