vigetlabs / blendid

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

Fix/run blendid after bin fix #533

Closed maoueh closed 6 years ago

maoueh commented 6 years ago

commit 73b30596ec9961320befc5325846d8cb6bc4ee1c

Fixed process.cwd() changes and reverted previous fixes

Changing from --gulpfile node_modules/blendid/gulpfile.js to --gulpfile node_modules/blendid/gulpfile.js/index.js had the unintended consequence of making the process.cwd() not the same being one directory lower than before.

As such, a workaround fix was performed in 19e4825 & 538c85c to make blendid assets now relative one level lower also.

This was not a proper fix and instead, the bin/blendid script has been updated to use one level lower by pointing to the previous directory directly instead of pointing to the main file of the directory. Previous modifications of previous workaround were reverted.

As part of testing, fixed a bunch of small globbing problem with Gulp like .gitkeep files not copied or some other files not ignored correctly.

commit 262796320d40cf60b45235655c4d2f6ccf33e126

Fix resolution of calling project package.json file (Fixes #532)

It appears that process.env.PWD is not consistent across platform as well as across sub-directory invocations. Indeed, even if it is consistent on Mac OS X (and probably Unix at the same time but untested), there is inconsitencies problem on Windows when using a POSIX transformer platform like Cygwin or MSYS2.

Indeed, in those cases, PWD is not the canonical Windows path but the original POSIX path of the terminal. Furthermore, invoking from a sub-directory also fiddles with the PWD adding subdirectory into it.

To fix that, it seems that Gulp is providing an environment variable that points to the root directory of the project and which is constant across platforms. See https://github.com/gulpjs/gulp/commit/2bf23ba407a594ac8ee7e693ec93b17dd906f926 for the actual INIT_CWD implementation.

So, to fix the problem everywhere, added a function resolveRelativeToProject that does the correct resolving using INIT_CWD environment variable instead of the previously used PWD.

To make stuff easier to use next time, a projectPath function was added that does the resolving of paths relative to the project root directory. All previous usages of path.(resolve|join (process.env.PWD, ...) that were used throughout the website are now using projectPath(...) instead.

Fixed bin script blendid/gulpfile.js/index.js resolution to use __dirname instead of require.resolve. The require.resolve does not work when using yarn link to development blendid features. Indeed, require.resolve does the resolution from the linked project leading to blendid not being resolvable (because not present in the linked node_modules directory). By using __dirname, we achieve the same goal as before but being more robust to linked project for development.

maoueh commented 6 years ago

I tested on Mac OS X the run part as well as all the init-* tasks, all good. I will test on Windows today night when I get home.

benjtinsley commented 6 years ago

based off @kferran's check it seems to be good. will merge. thanks again @maoueh!

maoueh commented 6 years ago

@benjtinsley Thanks for taking care of merging, this slipped through and I completely forgot to come back!