File tree Expand file tree Collapse file tree 3 files changed +13
-8
lines changed
Expand file tree Collapse file tree 3 files changed +13
-8
lines changed Original file line number Diff line number Diff line change @@ -154,8 +154,9 @@ target.bundle = function(argsArray) {
154154All commands run synchronously, unless otherwise stated.
155155
156156
157- ### cd('dir')
158- Changes to directory ` dir ` for the duration of the script
157+ ### cd([ dir] )
158+ Changes to directory ` dir ` for the duration of the script. Changes to home
159+ directory if no argument is supplied.
159160
160161
161162### pwd()
Original file line number Diff line number Diff line change @@ -2,11 +2,12 @@ var fs = require('fs');
22var common = require ( './common' ) ;
33
44//@
5- //@ ### cd('dir')
6- //@ Changes to directory `dir` for the duration of the script
5+ //@ ### cd([dir])
6+ //@ Changes to directory `dir` for the duration of the script. Changes to home
7+ //@ directory if no argument is supplied.
78function _cd ( options , dir ) {
89 if ( ! dir )
9- common . error ( 'directory not specified' ) ;
10+ dir = common . getUserHome ( ) ;
1011
1112 if ( dir === '-' ) {
1213 if ( ! common . state . previousDir )
Original file line number Diff line number Diff line change @@ -17,9 +17,6 @@ shell.mkdir('tmp');
1717// Invalids
1818//
1919
20- shell . cd ( ) ;
21- assert . ok ( shell . error ( ) ) ;
22-
2320assert . equal ( fs . existsSync ( '/asdfasdf' ) , false ) ; // sanity check
2421shell . cd ( '/adsfasdf' ) ; // dir does not exist
2522assert . ok ( shell . error ( ) ) ;
@@ -72,4 +69,10 @@ shell.cd('..');
7269shell . cd ( '~' ) ; // Change back to home
7370assert . equal ( process . cwd ( ) , common . getUserHome ( ) ) ;
7471
72+ // Goes to home directory if no arguments are passed
73+ shell . cd ( cur ) ;
74+ shell . cd ( ) ;
75+ assert . ok ( ! shell . error ( ) ) ;
76+ assert . equal ( process . cwd ( ) , common . getUserHome ( ) ) ;
77+
7578shell . exit ( 123 ) ;
You can’t perform that action at this time.
0 commit comments