https://github.com/scalajs-io/glob
A little globber
https://github.com/scalajs-io/glob
files glob node nodejs npm npm-package scala scalajs
Last synced: 9 months ago
JSON representation
A little globber
- Host: GitHub
- URL: https://github.com/scalajs-io/glob
- Owner: scalajs-io
- License: apache-2.0
- Created: 2017-02-10T22:38:18.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2019-06-17T23:09:02.000Z (over 6 years ago)
- Last Synced: 2025-01-17T22:42:33.879Z (11 months ago)
- Topics: files, glob, node, nodejs, npm, npm-package, scala, scalajs
- Language: Scala
- Size: 21.5 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Glob API for Scala.js
================================
This is a Scala.js type-safe binding for [glob](https://www.npmjs.com/package/glob)
A little globber.
#### Build Dependencies
* [SBT v1.2.x](http://www.scala-sbt.org/download.html)
#### Build/publish the SDK locally
```bash
$ sbt clean publish-local
```
#### Running the tests
Before running the tests the first time, you must ensure the npm packages are installed:
```bash
$ npm install
```
Then you can run the tests:
```bash
$ sbt test
```
#### Examples
##### Using `Glob` asynchronously via callbacks:
```scala
import io.scalajs.JSON
import io.scalajs.npm.glob._
Glob("**/*.scala", (err, files) => {
println(s"files: ${JSON.stringify(files)}")
})
```
##### Using `Glob` asynchronously via promises:
```scala
import io.scalajs.JSON
import io.scalajs.npm.glob._
import scalajs.concurrent.JSExecutionContext.Implicits.queue
Glob.future("**/*.scala") foreach { files =>
println(s"files: ${JSON.stringify(files)}")
}
```
##### Using `Glob` synchronously:
```scala
import io.scalajs.JSON
import io.scalajs.npm.glob._
val files = Glob.sync("**/*.scala", new GlobOptions())
println(s"files: ${JSON.stringify(files)}")
```
##### Using `Glob` as an instance:
```scala
import io.scalajs.JSON
import io.scalajs.npm.glob._
new Glob("**/*.scala", (err, files) => {
println(s"files: ${JSON.stringify(files)}")
})
```
##### The output from all of the examples is identical:
```text
files: ["src/main/scala/io/scalajs/npm/glob/Glob.scala","src/main/scala/io/scalajs/npm/glob/GlobOptions.scala",
"src/main/scala/io/scalajs/npm/glob/package.scala","src/test/scala/io/scalajs/npm/glob/GlobTest.scala"]
```
#### Artifacts and Resolvers
To add the `Glob` binding to your project, add the following to your build.sbt:
```sbt
libraryDependencies += "io.scalajs.npm" %%% "glob" % "0.5.0"
```
Optionally, you may add the Sonatype Repository resolver:
```sbt
resolvers += Resolver.sonatypeRepo("releases")
```