Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Making Modernizr friendlier for npm/cli #958

Merged
merged 2 commits into from
Jun 3, 2013

Conversation

doctyper
Copy link
Member

Related to #695.

I'm requesting a couple of small changes so that Modernizr and grunt-modernizr can better talk to each other. For the sake of clarity, I'll first detail my progress with porting the builder to explain my thought process.

I have a first draft available of a v3-friendly grunt-modernizr here for those that are interested in taking a look.

It makes sense (to me anyway) to import Modernizr as an npm module dependency. Since your build tool is already doing most of the work, I'm focusing on handling file parsing and test detection.

I'm using your metadata generator to retrieve the classes and/or test names I need to begin. I then use that data to dig through the current project and start parsing for matches. Once matched, I write the culled list of tests and options back to your lib/config-all.json file, and run grunt build to generate a customized build. All this happens behind-the-scenes and is invisible to the developer.

This seems to work really well. There are just a couple of integration edits I'd like to make:

  • First, I modified the meta generator to export its JSON rather than logging to console. This allows me to import the script as a module, instead of having to spawn a child task and having to capture stdout. Removing the log isn't necessary, but it does help to suppress a lot of white noise.
  • Second, and most importantly, I've promoted the devDependencies to actual dependencies. The reason is because npm install ignores devDependencies when installing, meaning I would not be able to run grunt build within this context.
  • Speaking of grunt build, I'm currently having to spawn a process to run the build task (I couldn't figure out how to weave the two grunt contexts together). This works, but is obviously not ideal. Has there been a thought to provide a programmatic API? The ideal scenario is to be able to run require("modernizr").build() and not have to worry about grunt context and the like.

Thanks, and please let me know your thoughts on this setup.

@stucox
Copy link
Member

stucox commented Jun 3, 2013

Looks ok to me, but @SlexAxton can you give your thoughts?

@SlexAxton
Copy link
Member

I use the console.log output now for easy debugging, but I can manage that locally I spose. This is fine with me. Will merge.

Happy to take a pull request for the require('modernizr').build() idea. I think the code is mostly in other spots, but the grunt specific stuff is weird to me, and I've never taken the time to really dig deep there.

SlexAxton added a commit that referenced this pull request Jun 3, 2013
Making Modernizr friendlier for npm/cli
@SlexAxton SlexAxton merged commit e74492b into Modernizr:master Jun 3, 2013
@doctyper doctyper mentioned this pull request Jun 4, 2013
patrickkettner pushed a commit to patrickkettner/Modernizr that referenced this pull request Feb 22, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants