@@ -20,18 +20,30 @@ async function assertOutDirIgnored (t, opts, existingDirectoryPath, pathToIgnore
20
20
await util . assertPathNotExists ( t , path . join ( resourcesPath , 'app' , ignoredBasenameToCheck ) , 'Out dir must not exist in output app directory' )
21
21
}
22
22
23
+ async function copyDirToTempDirWithIgnores ( t , opts ) {
24
+ ignore . generateIgnores ( opts )
25
+ const targetDir = path . join ( t . context . tempDir , 'result' )
26
+ await fs . copy ( opts . dir , targetDir , { dereference : false , filter : ignore . userIgnoreFilter ( opts ) } )
27
+ return targetDir
28
+ }
29
+
30
+ async function assertFileIgnored ( t , targetDir , ignoredFile ) {
31
+ await util . assertPathNotExists ( t , path . join ( targetDir , ignoredFile ) , `Ignored file '${ ignoredFile } ' should not exist in copied directory` )
32
+ }
33
+
34
+ async function assertFileNotIgnored ( t , targetDir , notIgnoredFile ) {
35
+ await util . assertPathExists ( t , path . join ( targetDir , notIgnoredFile ) , `The expected output directory should exist and contain ${ notIgnoredFile } ` )
36
+ }
37
+
23
38
async function ignoreTest ( t , opts , ignorePattern , ignoredFile ) {
24
39
opts . dir = util . fixtureSubdir ( 'basic' )
25
40
if ( ignorePattern ) {
26
41
opts . ignore = ignorePattern
27
42
}
28
43
29
- const targetDir = path . join ( t . context . tempDir , 'result' )
30
- ignore . generateIgnores ( opts )
31
-
32
- await fs . copy ( opts . dir , targetDir , { dereference : false , filter : ignore . userIgnoreFilter ( opts ) } )
33
- await util . assertPathExists ( t , path . join ( targetDir , 'package.json' ) , 'The expected output directory should exist and contain files' )
34
- await util . assertPathNotExists ( t , path . join ( targetDir , ignoredFile ) , `Ignored file '${ ignoredFile } ' should not exist in copied directory` )
44
+ const targetDir = await copyDirToTempDirWithIgnores ( t , opts )
45
+ await assertFileIgnored ( t , targetDir , ignoredFile )
46
+ await assertFileNotIgnored ( t , targetDir , 'package.json' )
35
47
}
36
48
37
49
async function ignoreOutDirTest ( t , opts , distPath ) {
@@ -72,6 +84,19 @@ test('ignore: RegExp', util.testSinglePlatform(ignoreTest, /ignorethis/, 'ignore
72
84
test ( 'ignore: Function' , util . testSinglePlatform ( ignoreTest , file => file . match ( / i g n o r e t h i s / ) , 'ignorethis.txt' ) )
73
85
test ( 'ignore: string with slash' , util . testSinglePlatform ( ignoreTest , 'ignore/this' , path . join ( 'ignore' , 'this.txt' ) ) )
74
86
test ( 'ignore: only match subfolder of app' , util . testSinglePlatform ( ignoreTest , 'electron-packager' , path . join ( 'electron-packager' , 'readme.txt' ) ) )
87
+
88
+ test ( 'ignore: junk by default' , util . testSinglePlatform ( async ( t , opts ) => {
89
+ opts . dir = util . fixtureSubdir ( 'ignore-junk' )
90
+ const targetDir = await copyDirToTempDirWithIgnores ( t , opts )
91
+ await assertFileIgnored ( t , targetDir , 'subfolder/Thumbs.db' )
92
+ } ) )
93
+ test ( 'ignore: not junk when junk: false' , util . testSinglePlatform ( async ( t , opts ) => {
94
+ opts . dir = util . fixtureSubdir ( 'ignore-junk' )
95
+ opts . junk = false
96
+ const targetDir = await copyDirToTempDirWithIgnores ( t , opts )
97
+ await assertFileNotIgnored ( t , targetDir , 'subfolder/Thumbs.db' )
98
+ } ) )
99
+
75
100
test . serial ( 'ignore out dir' , util . testSinglePlatform ( ignoreOutDirTest , 'ignoredOutDir' ) )
76
101
test . serial ( 'ignore out dir: unnormalized path' , util . testSinglePlatform ( ignoreOutDirTest , './ignoredOutDir' ) )
77
102
test . serial ( 'ignore out dir: implicit path' , util . testSinglePlatform ( async ( t , opts ) => {
0 commit comments