Closed augustl closed 4 years ago
What would happen if we make people type out "glob:/foo/*.js"
to use globbing?
Implementation wise that should be trivial. API design wise, I'm torn. A vector is cleaner than a stringly typed syntax thingie. But it's awfully convenient to use it.
We could add a fancy thing that supported symbols maybe..
(assets/load-bundles "public"
{"lib.js" ["/scripts/ext/angular.js"
:glob "/foo/*.js"
"/scripts/ext/another-file-here.js"] })
Not stringly typet, but also kind of weird.
[:glob "/foo/*.js"]
perhaps?
Seems like then ["foo" "*.js"]
is just as good... No strong opinions here though.
Maybe we can support these:
[:path "/foo/bar.js"]
[:regex #"foo/*.js"]
[:glob "/foo/*.js"]
And then normalize strings and regexps to their corresponding representation?
Yes, that's what I was thinking too. I would like to dispatch on something more explicit than vector?
Just force pushed an alternative version, based on the discussion so far. Thoughts?
Closing this after #70 introduced a better approach with normalising paths.
This works fine on Windows, provided https://github.com/magnars/optimus/pull/70 is merged.
The original idea behind using vectors was that we can't hard code / as a path separator. But after https://github.com/magnars/optimus/pull/70/, we can. So
["foo" "*.js"]
is compiled intoglob:/foo/*.js
and that works fine on both Windows and *nix.So the vector syntax is not really needed anymore.
Maybe an alternative approach could be to parse plain strings as glob patterns, and hope people don't already have a literal file named
"js/*.js"
?