1.2.2 • Published 10 years ago

exec-fallback v1.2.2

Weekly downloads
45
License
ISC
Repository
github
Last release
10 years ago

exec-fallback Build Status

Tool to fallback to an exec command in case that a method doesn't return a satisfactory value

Usage

Install with ...

$ npm install exec-fallback --save

and create a fallback in case a synchronous template is empty:

var fb = require('exec-fallback')
var myFallback = fb(function () {
    // do something
}, 'fallback-command')

Here is a example where pwd is called in case a config.path property doesn't exist.

var fb = require('exec-fallback')
function regularCall() {
    return config.path
}
var myConfigPath = fb(regularCall, 'pwd')

since the fallback is an async exec command you need to register a callback hook to get the value

myConfigPath(function (error, value) {
  // there will never be an error,
})

Caching & Invalidation

The result will be cached by default for 10 minutes. You can change the cache time by passing in a third parameter.

var myConfigPath = fb(regularCall, 'pwd', 100000)

It is also possible to invalidate the currently cached value.

myConfigPath.invalidate()

License

ISC

Originally inspired by osenv.

1.2.2

10 years ago

1.2.1

10 years ago

1.2.0

10 years ago

1.1.0

10 years ago

1.0.2

10 years ago

1.0.1

10 years ago

1.0.0

10 years ago