node-kit icon indicating copy to clipboard operation
node-kit copied to clipboard

Root directory files not found

Open ScottSmith95 opened this issue 7 years ago • 4 comments

I keep most of my kit partials in a folder in the root directory of my project. Currently, the only way to reference these files from a subdirectory is like so: ../kit-includes/foo.kit I would hope there is a way to improve this so I can just specify the root path and gulp-kit picks up the files there (like so: /kit-includes/foo.kit).

I thought this was an issue with gulp-kit, but I've been reviewing the code here and it seems that the issue is likely here. I would be willing to submit a pull request, but I don't quite know how the file lookups work.

ScottSmith95 avatar Aug 30 '16 14:08 ScottSmith95

The file lookups are simple enough. Give a string and it checks if the file is present. The root dir should not be of any concern. You can try using it as a cli tool if that's more convenient for verification.

fatso83 avatar Aug 30 '16 15:08 fatso83

The line @fatso83 linked is only for locating the starting file. The file lookup is handled by the Kit.prototype._findFile method.

It would be simple enough to add an optional parameter for import paths, which could then be exposed in gulp-kits options.

jeremyworboys avatar Aug 31 '16 01:08 jeremyworboys

That's what I thought. It seems line 369 is responsible for the relative file path finding, but maybe it doesn't work for root directories. This is where my knowledge kind of runs out.

ScottSmith95 avatar Aug 31 '16 01:08 ScottSmith95

The current findFile implementation only checks the following in this order:

Line Type Variant Example
372 absolute typed /home/username/example/kit-includes/foo.kit
373 relative typed ../kit-includes/foo.kit
374 absolute alternate /home/username/example/kit-includes/_foo.kit
375 relative alternate ../kit-includes/_foo.kit

Where relative is from the file declaring the import and absolute is from the filesystem root.

Where typed is the path that appears in the import declaration and alternate is either with or without an underscored filename.

jeremyworboys avatar Aug 31 '16 01:08 jeremyworboys