File tree Expand file tree Collapse file tree 5 files changed +34
-2
lines changed
Expand file tree Collapse file tree 5 files changed +34
-2
lines changed Original file line number Diff line number Diff line change @@ -75,7 +75,7 @@ function _mkdir(options, dirs) {
7575
7676 try {
7777 if ( options . fullpath ) {
78- mkdirSyncRecursive ( dir ) ;
78+ mkdirSyncRecursive ( path . resolve ( dir ) ) ;
7979 } else {
8080 fs . mkdirSync ( dir , parseInt ( '0777' , 8 ) ) ;
8181 }
Original file line number Diff line number Diff line change @@ -259,7 +259,6 @@ test(
259259) ;
260260
261261test ( 'recursive, everything exists, no force flag' , t => {
262- shell . cp ( '-R' , 'resources/cp' , t . context . tmp ) ;
263262 const result = shell . cp ( '-R' , 'resources/cp' , t . context . tmp ) ;
264263 t . falsy ( shell . error ( ) ) ; // crash test only
265264 t . falsy ( result . stderr ) ;
@@ -647,3 +646,10 @@ test('Test with recursive option and symlinks.', t => {
647646 t . falsy ( shell . test ( '-L' , 'sym.lnk' ) ) ;
648647 } ) ;
649648} ) ;
649+
650+ test ( 'recursive, with a non-normalized path' , t => {
651+ const result = shell . cp ( '-R' , 'resources/../resources/./cp' , t . context . tmp ) ;
652+ t . falsy ( shell . error ( ) ) ; // crash test only
653+ t . falsy ( result . stderr ) ;
654+ t . is ( result . code , 0 ) ;
655+ } ) ;
Original file line number Diff line number Diff line change @@ -466,3 +466,13 @@ test('Check stderr field', t => {
466466 t . truthy ( shell . error ( ) ) ;
467467 t . is ( 'ls: no such file or directory: /asdfasdf' , result . stderr ) ;
468468} ) ;
469+
470+ test ( 'non-normalized paths are still ok with -R' , t => {
471+ const result = shell . ls ( '-R' , 'resources/./ls/../ls' ) ;
472+ t . falsy ( shell . error ( ) ) ;
473+ t . is ( result . code , 0 ) ;
474+ t . truthy ( result . indexOf ( 'a_dir' ) > - 1 ) ;
475+ t . truthy ( result . indexOf ( 'a_dir/b_dir' ) > - 1 ) ;
476+ t . truthy ( result . indexOf ( 'a_dir/b_dir/z' ) > - 1 ) ;
477+ t . is ( result . length , 9 ) ;
478+ } ) ;
Original file line number Diff line number Diff line change @@ -147,3 +147,10 @@ test('globbed dir', t => {
147147 t . truthy ( fs . existsSync ( `${ t . context . tmp } /mydir` ) ) ;
148148 t . falsy ( fs . existsSync ( `${ t . context . tmp } /m*ir` ) ) ; // doesn't create literal name
149149} ) ;
150+
151+ test ( 'non-normalized paths are still ok with -p' , t => {
152+ const result = shell . mkdir ( '-p' , `${ t . context . tmp } /asdf/../asdf/./` ) ;
153+ t . falsy ( shell . error ( ) ) ;
154+ t . is ( result . code , 0 ) ;
155+ t . truthy ( fs . existsSync ( `${ t . context . tmp } /asdf` ) ) ;
156+ } ) ;
Original file line number Diff line number Diff line change @@ -282,3 +282,12 @@ test('remove broken symbolic link', t => {
282282 t . falsy ( fs . existsSync ( `${ t . context . tmp } /rm/fake.lnk` ) ) ;
283283 }
284284} ) ;
285+
286+ test ( 'recursive dir removal, for non-normalized path' , t => {
287+ shell . mkdir ( '-p' , `${ t . context . tmp } /a/b/c` ) ;
288+ t . truthy ( fs . existsSync ( `${ t . context . tmp } /a/b/c` ) ) ;
289+ const result = shell . rm ( '-rf' , `${ t . context . tmp } /a/.././a` ) ;
290+ t . falsy ( shell . error ( ) ) ;
291+ t . is ( result . code , 0 ) ;
292+ t . falsy ( fs . existsSync ( `${ t . context . tmp } /a` ) ) ;
293+ } ) ;
You can’t perform that action at this time.
0 commit comments