UNPKG

base-cli-process

Version:

Normalizers for common argv commands handled by the base-cli plugin. Also pre-processes the given object with base-cli-schema before calling `.process()`

33 lines (26 loc) 683 B
'use strict'; var path = require('path'); var debug = require('../debug'); var utils = require('../utils'); /** * Set a `dest` path on `app.options`. * * ```sh * $ app --dest=foo * ``` * @name dest * @api public */ module.exports = function(app) { var dests = app.options.dest ? [app.options.dest] : [app.cwd]; return function(val, key, config, next) { debug.field(key, val); app.options.dest = path.resolve(val); if (dests[dests.length - 1] !== app.options.dest) { var dir = utils.magenta('~/' + utils.homeRelative(app.options.dest)); utils.timestamp('using dest path ' + dir); dests.push(app.options.dest); } next(); }; };