Skip to content

scalajs-io/glob

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

Using Glob asynchronously via callbacks:
import io.scalajs.JSON
import io.scalajs.npm.glob._

Glob("**/*.scala", (err, files) => {
  println(s"files: ${JSON.stringify(files)}")
})
Using Glob asynchronously via promises:
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:
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:
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")