Closed nporteschaikin closed 7 years ago
I've only briefly dabbled in node, so not sure what that would require, but agreed that would be a useful feature.
Thanks for adding AMD/CommonJS support!
Closing this out since I think Sherlock works as-is with Node by installing the sherlockjs
npm module and just defining Watson somewhere in your code before using Sherlock.
hey @neilgupta, would you consider/accept a PR that implements what i'm describing here:? https://github.com/commitsto/commits.to/issues/191#issuecomment-390445202
Yup, those all sound like reasonable changes. Sherlock really should check if Watson has the method implemented before trying to call it, and I'm +1 passing the Watson object directly to parse.
Rather than an init method, I think I'd prefer adding separate config
, preprocess
, and postprocess
methods to Sherlock.
@neilgupta so i basically ended up going a little off the deep end haha!
i ported everything over to es6 and refactoring sherlock and watson into classes (with watson containing all the patterns, etc. which can be overridden or customized individually). i also converted the tests to run in mocha, and set up a babel build step to create the browser-compatible bundles.
it's been done for a while but i haven't had a chance to update the README to document my changes, though i'm working on that now...
my question is, would you be open to merging in such a large refactor?
Heh, those all sound like fun enhancements, but unfortunately they don't make sense for merging into the main project. Sherlock is meant to be a lightweight pure JS library, and has no opinions on your build tooling.
@neilgupta ahh sorry if i'm not really explaining it correctly. those changes are for the development process (e.g. converting the tests lets me run them on a CI instance), the end product is still the same
the babel build step is to take the es6 code and transpile it into both a node module package and pure js library. it's a pretty common workflow with node packages, and the minified sherlock/watson browser (umd) script bundle is basically same size as the current sherlock.js file if it were minified
I think making this Node-friendly may require refactoring Watson into Sherlock more directly, or possibly refactoring Sherlock to be more object-oriented.
AMD compatibility is simple.
I love the script!