-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcwd.js
More file actions
32 lines (27 loc) · 633 Bytes
/
cwd.js
File metadata and controls
32 lines (27 loc) · 633 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
'use strict';
var path = require('path');
var debug = require('../debug');
var utils = require('../utils');
/**
* Set the `--cwd` to use in the current project.
*
* ```sh
* $ app --cwd=foo
* ```
* @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;
var dir = utils.magenta('~/' + utils.homeRelative(val));
utils.timestamp('changing cwd to ' + dir);
cwds.push(val);
}
next();
};
};