ConsenSysMesh / solidity-parser

Solidity Parser in Javascript
137 stars 53 forks source link

Add a prepare script so that build is run on publish or install #64

Closed frangio closed 7 years ago

frangio commented 7 years ago

This removes the build directory from the repo and instead adds a prepare task that npm will automatically run when installing the package locally or before publishing it.

Since build is now in .gitignore it's also necessary to have an empty .npmignore file. This way the build directory will be included in the package.

frangio commented 7 years ago

Travis failed because it uses npm 3.8.6 and prepare was introduced in 4.0.0.

I've changed it to prepublish which is the <4.0.0 equivalent.

federicobond commented 7 years ago

I like this, but Truffle supports Windows and I think it will fail in those systems. Someone has suggested using https://www.npmjs.com/package/mkdirp but it may not be worth it.

frangio commented 7 years ago

Oh, it's true, mkdir -p won't work on Windows. I just went ahead and added the mkdirp package as a dev dependency. It's worth it IMO.

federicobond commented 7 years ago

LGTM

federicobond commented 7 years ago

Rebased and merged manually. Commits are still attributed to you.

elenadimitrova commented 7 years ago

There is an issue with yarn https://github.com/yarnpkg/yarn/issues/1671 which means the prepublish isn't run when yarn runs. We then start getting a Error: Cannot find module './build/parser'

federicobond commented 7 years ago

Thanks for pointing this out @elenadimitrova. There doesn't seem to be a clear solution for this problem. In the meantime, I suggest sticking with npm. The latest major version should dramatically improve install time, which was one of the main causes that prompted the creation of yarn.