@art-suite/source-root-finder

ArtSuite.SourceRootFinder

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
@art-suite/source-root-finder
211.0.11a year ago2 years agoMinified + gzip package size for @art-suite/source-root-finder in KB

Readme

ArtSuite.SourceRootFinder
  • Purpose: given a path to a directory or file, find the root directory of that containing project.
  • Strategy: look in the specified directory and each parent directory for files matching the names of one of the indicatory files/directories (default: package.json and .git)

Install

npm install @art-suite/source-root-finder

Usage

{SourceRootFinder, findSourceRoot, findSourceRootSync} = require "@art-suite/source-root-finder"

# find with max async to not tie up the process; returns a Promise
findSourceRoot "./"
# .then (result) -> result === "~/myProject"

# just give me the results right now! - returns the string
findSourceRootSync "./"
# === "~/myProject"

# custom source-root-finder
myRubySourceRootFinder = indicatorFiles: ["Rakefile", ".gemspec"]
myRubySourceRootFinder.findSourceRootSync "~/dev/myRubyProject/src/deep/in/a/ruby/project"
# === "~/dev/myRubyProject"