@@ -29,14 +29,18 @@ test('cwd', async t => {
29
29
t . is ( read ( t . context . tmp , 'cwd/hello.js' ) , read ( t . context . tmp , 'cwd/dest/hello.js' ) ) ;
30
30
} ) ;
31
31
32
- test ( 'keep path structure with flag `--parents` ' , async t => {
32
+ test ( 'path structure' , async t => {
33
33
fs . mkdirSync ( t . context . tmp ) ;
34
34
fs . mkdirSync ( path . join ( t . context . tmp , 'cwd' ) ) ;
35
+ fs . mkdirSync ( path . join ( t . context . tmp , 'out' ) ) ;
35
36
fs . writeFileSync ( path . join ( t . context . tmp , 'cwd/hello.js' ) , 'console.log("hello");' ) ;
36
37
37
- await execa ( './cli.js' , [ path . join ( t . context . tmp , 'cwd/hello.js ' ) , t . context . tmp , '--parents' ] ) ;
38
+ await execa ( './cli.js' , [ path . join ( t . context . tmp , '** ' ) , path . join ( t . context . tmp , 'out' ) ] ) ;
38
39
39
- t . is ( read ( t . context . tmp , 'cwd/hello.js' ) , read ( t . context . tmp , t . context . tmp , 'cwd/hello.js' ) ) ;
40
+ t . is (
41
+ read ( t . context . tmp , 'cwd/hello.js' ) ,
42
+ read ( t . context . tmp , 'out/cwd/hello.js' ) ,
43
+ ) ;
40
44
} ) ;
41
45
42
46
test ( 'rename filenames but not filepaths' , async t => {
@@ -68,9 +72,32 @@ test('do not copy files in the negated glob patterns', async t => {
68
72
fs . writeFileSync ( path . join ( t . context . tmp , 'src/hello.jsx' ) , 'console.log("world");' ) ;
69
73
fs . writeFileSync ( path . join ( t . context . tmp , 'src/hello.es2015' ) , 'console.log("world");' ) ;
70
74
71
- await execa ( './cli.js' , [ 'src/*.*' , '!src/*.jsx' , '!src/*.es2015' , 'dest' , '--cwd' , t . context . tmp ] ) ;
75
+ await execa ( './cli.js' , [ 'src/*.*' , '!src/*.jsx' , '!src/*.es2015' , path . join ( t . context . tmp , 'dest' ) , '--cwd' , t . context . tmp ] ) ;
72
76
73
77
t . is ( read ( t . context . tmp , 'dest/hello.js' ) , 'console.log("hello");' ) ;
74
78
t . false ( pathExistsSync ( path . join ( t . context . tmp , 'dest/hello.jsx' ) ) ) ;
75
79
t . false ( pathExistsSync ( path . join ( t . context . tmp , 'dest/hello.es2015' ) ) ) ;
76
80
} ) ;
81
+
82
+ test ( 'flatten directory tree' , async t => {
83
+ fs . mkdirSync ( t . context . tmp ) ;
84
+ fs . mkdirSync ( path . join ( t . context . tmp , 'source' ) ) ;
85
+ fs . mkdirSync ( path . join ( t . context . tmp , 'source' , 'nested' ) ) ;
86
+ fs . writeFileSync ( path . join ( t . context . tmp , 'foo.js' ) , 'console.log("foo");' ) ;
87
+ fs . writeFileSync ( path . join ( t . context . tmp , 'source/bar.js' ) , 'console.log("bar");' ) ;
88
+ fs . writeFileSync ( path . join ( t . context . tmp , 'source/nested/baz.ts' ) , 'console.log("baz");' ) ;
89
+
90
+ await execa ( './cli.js' , [ '**/*.js' , 'destination/subdir' , '--cwd' , t . context . tmp , '--flat' ] ) ;
91
+
92
+ t . is (
93
+ read ( t . context . tmp , 'foo.js' ) ,
94
+ read ( t . context . tmp , 'destination/subdir/foo.js' ) ,
95
+ ) ;
96
+ t . is (
97
+ read ( t . context . tmp , 'source/bar.js' ) ,
98
+ read ( t . context . tmp , 'destination/subdir/bar.js' ) ,
99
+ ) ;
100
+ t . falsy (
101
+ fs . existsSync ( path . join ( t . context . tmp , 'destination/subdir/baz.ts' ) ) ,
102
+ ) ;
103
+ } ) ;