@@ -16,30 +16,11 @@ const isWin = process.platform === "win32"
16
16
17
17
const rootPath = path . resolve ( __dirname , ".." )
18
18
const testPath = path . resolve ( rootPath , "test" )
19
- const buildPath = path . resolve ( rootPath , "build" )
20
19
const envPath = path . resolve ( testPath , "env" )
21
20
const esmPath = path . resolve ( rootPath , "esm.js" )
22
21
const indexPath = path . resolve ( rootPath , "index.js" )
23
- const loaderDirPath = path . resolve ( rootPath , "esm" )
24
22
const mochaPath = path . resolve ( rootPath , "node_modules/mocha/bin/_mocha" )
25
23
const nodePath = path . resolve ( envPath , "prefix" , isWin ? "node.exe" : "bin/node" )
26
- const nodeModulesPath = path . resolve ( rootPath , "node_modules" )
27
- const vendorPath = path . resolve ( rootPath , "src/vendor" )
28
-
29
- const uglifyOptions = fs . readJSONSync ( path . resolve ( rootPath , ".uglifyrc" ) )
30
-
31
- const jsPaths = [
32
- esmPath ,
33
- indexPath
34
- ]
35
-
36
- const trashPaths = ignorePaths
37
- . filter ( ( thePath ) =>
38
- thePath !== loaderDirPath &&
39
- thePath !== nodeModulesPath &&
40
- ! thePath . startsWith ( buildPath ) &&
41
- ! thePath . startsWith ( vendorPath )
42
- )
43
24
44
25
const NODE_ENV = argv . prod ? "production" : "development"
45
26
const ESM_ENV = NODE_ENV + "-test"
@@ -50,6 +31,19 @@ const NODE_PATH = [
50
31
path . resolve ( envPath , "node_path/relative" )
51
32
] . join ( path . delimiter )
52
33
34
+ const jsPaths = [
35
+ esmPath ,
36
+ indexPath
37
+ ]
38
+
39
+ const keptPaths = [
40
+ path . resolve ( rootPath , "build" ) ,
41
+ path . resolve ( rootPath , "esm" ) ,
42
+ path . resolve ( rootPath , "node_modules" ) ,
43
+ path . resolve ( rootPath , "src/vendor" ) ,
44
+ path . resolve ( rootPath , "test/vendor" )
45
+ ]
46
+
53
47
const nodeArgs = [ ]
54
48
55
49
if ( process . env . HARMONY ) {
@@ -63,6 +57,9 @@ nodeArgs.push(
63
57
"tests.js"
64
58
)
65
59
60
+ const trashPaths = ignorePaths . filter ( isKept )
61
+ const uglifyOptions = fs . readJSONSync ( path . resolve ( rootPath , ".uglifyrc" ) )
62
+
66
63
function cleanJS ( ) {
67
64
jsPaths . forEach ( ( filename ) => {
68
65
const content = fs . readFileSync ( filename , "utf8" )
@@ -77,6 +74,10 @@ function cleanRepo() {
77
74
return Promise . all ( trashPaths . map ( trash ) )
78
75
}
79
76
77
+ function isKept ( thePath ) {
78
+ return keptPaths . every ( ( dirname ) => ! thePath . startsWith ( dirname ) )
79
+ }
80
+
80
81
function minifyJS ( content ) {
81
82
return uglify ( content , uglifyOptions ) . code
82
83
}
0 commit comments