|
9 | 9 |
|
10 | 10 | exec = child_process.exec, |
11 | 11 | tryCatch = require('try-catch'), |
| 12 | + untildify = require('untildify'), |
12 | 13 |
|
13 | 14 | WIN = process.platform === 'win32', |
14 | 15 | spawn = child_process.spawn, |
|
30 | 31 | assert(command, 'command could not be empty!'); |
31 | 32 |
|
32 | 33 | if (options && options.cwd) |
33 | | - options.cwd = parseDir(options.cwd); |
| 34 | + options.cwd = untildify(options.cwd); |
34 | 35 | else |
35 | 36 | options = { |
36 | 37 | cwd: process.cwd() |
|
41 | 42 | return spawnify; |
42 | 43 | }; |
43 | 44 |
|
44 | | - function getHome() { |
45 | | - var HOME_WIN = process.env.HOMEPATH, |
46 | | - HOME_UNIX = process.env.HOME, |
47 | | - HOME = HOME_WIN || HOME_UNIX; |
48 | | - |
49 | | - return HOME; |
50 | | - } |
51 | | - |
52 | 45 | function parseDir(dir) { |
53 | | - var home = getHome(), |
54 | | - cwd = process.cwd(); |
| 46 | + var cwd = process.cwd(); |
55 | 47 |
|
56 | 48 | assert(dir, 'dir should be string!'); |
57 | 49 |
|
58 | | - dir = dir.replace(/^~/, home) |
59 | | - .replace(/^\./, cwd); |
| 50 | + dir = dir.replace(/^\./, cwd); |
60 | 51 |
|
61 | 52 | return dir; |
62 | 53 | } |
|
245 | 236 | var wasError, strs, |
246 | 237 | self = this, |
247 | 238 | CD = 'cd ', |
248 | | - HOME = getHome(), |
249 | 239 |
|
250 | 240 | isChangeVolume = win.isChangeVolume(command), |
251 | 241 | isVolume = win.isVolume(command), |
252 | 242 | paramDir, |
253 | 243 |
|
254 | | - regExpHome = RegExp('^~'), |
255 | 244 | regExpRoot = RegExp('^[/\\\\]'), |
256 | 245 |
|
257 | 246 | isWildCard, |
258 | | - isHome = regExpHome.test(command) && !WIN, |
259 | 247 | isRoot; |
260 | 248 |
|
261 | 249 | this.on('error', function() { |
|
267 | 255 | this._emit('path', paramDir); |
268 | 256 | }); |
269 | 257 |
|
270 | | - if (isHome) |
271 | | - command = command.replace('~', HOME); |
272 | | - |
273 | | - paramDir = command; |
| 258 | + paramDir = untildify(command); |
274 | 259 | isWildCard = isContain(paramDir, ['*', '?']); |
275 | 260 |
|
276 | 261 | if (!paramDir && !WIN) |
|
293 | 278 | command = command.replace(str, ''); |
294 | 279 | }); |
295 | 280 |
|
296 | | - if (!isHome && !isRoot) |
| 281 | + if (!isRoot) |
297 | 282 | paramDir = path.join(currDir, paramDir); |
298 | 283 |
|
299 | 284 | if (isWildCard) |
|
0 commit comments