vigetlabs / blendid

A delicious blend of gulp tasks combined into a configurable asset pipeline and static site builder
MIT License
4.97k stars 680 forks source link

Fixed bin script module resolving #471

Closed maoueh closed 6 years ago

maoueh commented 7 years ago

When using a tool like Lerna with hoisting (common dependencies installed in project root node_modules and not sub-project node_modules) or upcoming Yarn workspaces support, the resolving of blendid gulp main task file as well as gulp itself is broken.

The current script assumes resolution in the package directory while with these kind of tool, it get installed higher in the project hierarchy.

To solve this, we switched to require.resolve to resolve the actual location of the required files. This uses Node.js resolution mechanism to find the right package location.

The downside is that require.resolve returns the actual entry file and not the base package directory (blendid/gulpfile.js/index.js for require.resolve('blendid')). The implications is that if the entry file changes for blendid or gulp, the script is broken.

All in all, since we depends explicitly on particular versions of gulp, it should not be a problem to keep it in sync.

maoueh commented 7 years ago

Can it be possible to have a look at this PR? I need to keep a customized bin/blendid script in all my projects now. I would like to remove it if possible :)