question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItΒ collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

add globstar (asterisk) support for imports

See original GitHub issue

It would be really nice if we could use globstars to import directories of stylus files.

For example, with a directory structure like this (from an animate.css port):

β”œβ”€β”€ flippers
β”‚Β Β  β”œβ”€β”€ flip.styl
β”‚Β Β  β”œβ”€β”€ flipInX.styl
β”‚Β Β  β”œβ”€β”€ flipInY.styl
β”‚Β Β  β”œβ”€β”€ flipOutX.styl
β”‚Β Β  β”œβ”€β”€ flipOutY.styl
β”œβ”€β”€ lightspeed
β”‚Β Β  β”œβ”€β”€ lightSpeedIn.styl
β”‚Β Β  └── lightSpeedOut.styl
β”œβ”€β”€ rotating_entrances
β”‚Β Β  β”œβ”€β”€ rotateIn.styl
β”‚Β Β  β”œβ”€β”€ rotateInDownLeft.styl
β”‚Β Β  β”œβ”€β”€ rotateInDownRight.styl
β”‚Β Β  β”œβ”€β”€ rotateInUpLeft.styl
β”‚Β Β  └── rotateInUpRight.styl
β”œβ”€β”€ rotating_exits
β”‚Β Β  β”œβ”€β”€ rotateOut.styl
β”‚Β Β  β”œβ”€β”€ rotateOutDownLeft.styl
β”‚Β Β  β”œβ”€β”€ rotateOutDownRight.styl
β”‚Β Β  β”œβ”€β”€ rotateOutUpLeft.styl
β”‚Β Β  └── rotateOutUpRight.styl
β”œβ”€β”€ sliders
β”‚Β Β  β”œβ”€β”€ slideInDown.styl
β”‚Β Β  β”œβ”€β”€ slideInLeft.styl
β”‚Β Β  β”œβ”€β”€ slideInRight.styl
β”‚Β Β  β”œβ”€β”€ slideOutLeft.styl
β”‚Β Β  β”œβ”€β”€ slideOutRight.styl
β”‚Β Β  └── slideOutUp.styl
β”œβ”€β”€ specials
β”‚   β”œβ”€β”€ hinge.styl
β”‚   β”œβ”€β”€ rollIn.styl
β”‚   └── rollOut.styl
β”œβ”€β”€ package.json
β”œβ”€β”€ bower.json
└── README.md

We could use @import 'animate.css/*' to import everything in the library, or @import 'animate.css/sliders/*' to get only the sliders, or @import 'animate.css/sliders/slideInDown' to get only the slideInDown animation.

I know that we can do this already by adding an index.styl to each folder with a list of @imports for files in that folder. However, that requires a lot of extra files that need to be kept in sync with any removals or additions to the directory they are in.

Edit: as @jasonkuhrt mentions below, we could use https://github.com/isaacs/node-glob for the implementation.

Issue Analytics

  • State:closed
  • Created 10 years ago
  • Comments:11 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
Panyacommented, Oct 18, 2016

And even if they would be supported, we can’t use glob patterns there because we don’t have full access to the filesystem in client side JS.

1reaction
hiulitcommented, Oct 18, 2016

Is this possible using the client side version of stylus? Because I’m getting an error β€œglob is not defined”. Thanks.

Read more comments on GitHub >

github_iconTop Results From Across the Web

What double ** do in an import? - Stack Overflow
A double asterisk translates to any character, which means not only file names but also directories are taken into account (and so ....
Read more >
Working with Globs | Forestry.io
Two asterisks in sequence ( ** ) is known as a globstar and will match 0 or more subdirectories in the path.
Read more >
How to enable the double star ** (globstar) operator?
1 Answer 1 ; echo $BASH_VERSION 4.4.12(1)-release. Check if it is enabled via: ; shopt globstar. It defaults to off . If you...
Read more >
path/filepath: Glob should support ** for zero or more ... - GitHub
Go version 1.4.2 Mac OS X 10.10 Example: package main import "fmt" import "path/filepath" import "os" func main() { files, err := filepath....
Read more >
glob β€” Unix style pathname pattern expansion ... - Python Docs
This function can support paths relative to directory descriptors with the dir_fd parameter. If recursive is true, the pattern β€œ ** ” will...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found