1.29.0 • Published 1 year ago

@wmfs/concrete-paths v1.29.0

Weekly downloads
2
License
MIT
Repository
github
Last release
1 year ago

concrete-paths

npm (scoped) CircleCI codecov CodeFactor Dependabot badge Commitizen friendly JavaScript Style Guide license FOSSA Status

An option-laden utility which takes general glob-paths, delimited paths etc. and returns an array of absolute paths.

Install

$ npm install concrete-paths --save

Usages

Given a directory containing:

/stuff
  /lib
    file1.js
    file2.js
  /logs
    log1.txt
    log2.txt
  /node_modules
    /some-package1
      foo.txt
      bar.txt
    /some-package2
      foo.txt
      bar.txt
  /test    
    test1.js
    test2.js
    

Then concrete-paths can be used in the following ways:

Usage 1: Simple glob-pattern string usage

Please see the glob package's Glob Primer for more information with working with glob patterns.

const concretePaths = require('concrete-paths')

concretePaths('/stuff/**/*.js').then(
  function(result) {
    // Result:
    // [
    //   '/stuff/lib/file1.js',
    //   '/stuff/lib/file2.js',
    //   '/stuff/test/test1.js',
    //   '/stuff/test/test2.js'
    // ]
  }
)

Usage 2: Single ; delimited string

Useful when working with values derived from environment variables.

const concretePaths = require('concrete-paths')

concretePaths('/stuff/lib/*.js;/stuff/logs/*.js').then(
  function(result) {
    // Result:
    // [
    //   '/stuff/lib/file1.js',
    //   '/stuff/lib/file2.js',
    //   '/stuff/logs/log1.txt',
    //   '/stuff/logs/log2.txt'
    // ]
  }
)

Usage 3: Multiple strings via array

Mix-and-match delimited strings, globs etc. in an array of strings.

const concretePaths = require('concrete-paths')

concretePaths(
  [
    '/stuff/node_modules/some-package1/*',
    '/stuff/lib/*.js;/stuff/logs/*.js'
  ]  
).then(
  function(result) {
    // Result:
    // [
    //   '/stuff/node_modules/some-package1/foo.txt',
    //   '/stuff/node_modules/some-package1/bar.txt',
    //   '/stuff/lib/file1.js',
    //   '/stuff/lib/file2.js',
    //   '/stuff/logs/log1.txt',
    //   '/stuff/logs/log2.txt'
    // ]
  }
)

API

concretePaths(sourcePaths, [options]) returns promise

sourcePaths

options

OptionTypeNotes

Testing

$ npm test

License

MIT

FOSSA Status

1.29.0

1 year ago

1.27.0

2 years ago

1.28.0

2 years ago

1.26.0

3 years ago

1.25.0

3 years ago

1.24.0

3 years ago

1.23.0

3 years ago

1.22.0

3 years ago

1.21.0

3 years ago

1.20.0

4 years ago

1.19.0

4 years ago

1.18.0

4 years ago

1.17.0

4 years ago

1.16.0

4 years ago

1.15.0

4 years ago

1.14.0

4 years ago

1.13.0

4 years ago

1.12.0

5 years ago

1.11.0

5 years ago

1.10.0

5 years ago

1.9.0

5 years ago

1.8.0

5 years ago

1.7.0

5 years ago

1.6.0

6 years ago

1.5.0

6 years ago

1.4.0

6 years ago

1.3.0

6 years ago

1.2.0

6 years ago

1.1.0

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago