Glob API for Scala.js
This is a Scala.js type-safe binding for glob
A little globber.
Build Dependencies
Build/publish the SDK locally
$ sbt clean publish-local
Running the tests
Before running the tests the first time, you must ensure the npm packages are installed:
$ npm install
Then you can run the tests:
$ sbt test
Examples
Glob
asynchronously via callbacks:
Using import io.scalajs.JSON
import io.scalajs.npm.glob._
Glob("**/*.scala", (err, files) => {
println(s"files: ${JSON.stringify(files)}")
})
Glob
asynchronously via promises:
Using 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)}")
}
Glob
synchronously:
Using import io.scalajs.JSON
import io.scalajs.npm.glob._
val files = Glob.sync("**/*.scala", new GlobOptions())
println(s"files: ${JSON.stringify(files)}")
Glob
as an instance:
Using 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:
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:
libraryDependencies += "io.scalajs.npm" %%% "glob" % "0.5.0"
Optionally, you may add the Sonatype Repository resolver:
resolvers += Resolver.sonatypeRepo("releases")