base-config-process
Version:
Commonly used config mappings for the base-config plugin. Also pre-processes the given object with base-config-schema before calling `.process()`
35 lines (29 loc) • 542 B
JavaScript
;
var debug = require('../debug');
var path = require('path');
/**
* Set the current working directory.
*
* ```json
* {
* "name": "my-project",
* "verb": {
* "cwd": "foo/bar"
* }
* }
* ```
* @name cwd
* @api public
*/
module.exports = function(app) {
var cwds = [app.cwd || process.cwd()];
return function(val, key, config, next) {
debug.field(key, val);
val = path.resolve(val);
if (cwds[cwds.length - 1] !== val) {
app.cwd = val;
cwds.push(val);
}
next();
};
};