|
17 | 17 | * under the License. |
18 | 18 | */ |
19 | 19 |
|
20 | | -import { deleteAll } from '../lib'; |
| 20 | +import minimatch from 'minimatch'; |
| 21 | + |
| 22 | +import { deleteAll, scanDelete } from '../lib'; |
21 | 23 |
|
22 | 24 | export const CleanTask = { |
23 | 25 | global: true, |
@@ -49,105 +51,122 @@ export const CleanTypescriptTask = { |
49 | 51 | 'Cleaning typescript source files that have been transpiled to JS', |
50 | 52 |
|
51 | 53 | async run(config, log, build) { |
52 | | - await deleteAll(log, [ |
53 | | - build.resolvePath('**/*.{ts,tsx,d.ts}'), |
54 | | - build.resolvePath('**/tsconfig*.json'), |
55 | | - ]); |
| 54 | + log.info('Deleted %d files', await scanDelete({ |
| 55 | + directory: build.resolvePath(), |
| 56 | + regularExpressions: [ |
| 57 | + /\.(ts|tsx|d\.ts)$/, |
| 58 | + /tsconfig.*\.json$/ |
| 59 | + ] |
| 60 | + })); |
56 | 61 | }, |
57 | 62 | }; |
58 | 63 |
|
59 | 64 | export const CleanExtraFilesFromModulesTask = { |
60 | 65 | description: 'Cleaning tests, examples, docs, etc. from node_modules', |
61 | 66 |
|
62 | 67 | async run(config, log, build) { |
63 | | - const deleteFromNodeModules = globs => { |
64 | | - return deleteAll( |
65 | | - log, |
66 | | - globs.map(p => build.resolvePath(`node_modules/**/${p}`)) |
| 68 | + const makeRegexps = patterns => |
| 69 | + patterns.map(pattern => |
| 70 | + minimatch.makeRe(pattern, { nocase: true }) |
67 | 71 | ); |
68 | | - }; |
69 | 72 |
|
70 | | - const tests = [ |
71 | | - 'test', |
72 | | - 'tests', |
73 | | - '__tests__', |
74 | | - 'mocha.opts', |
75 | | - '*.test.js', |
76 | | - '*.snap', |
77 | | - 'coverage', |
78 | | - ]; |
79 | | - const docs = [ |
80 | | - 'doc', |
81 | | - 'docs', |
82 | | - 'CONTRIBUTING.md', |
83 | | - 'Contributing.md', |
84 | | - 'contributing.md', |
85 | | - 'History.md', |
86 | | - 'HISTORY.md', |
87 | | - 'history.md', |
88 | | - 'CHANGELOG.md', |
89 | | - 'Changelog.md', |
90 | | - 'changelog.md', |
91 | | - ]; |
92 | | - const examples = ['example', 'examples', 'demo', 'samples']; |
93 | | - const bins = ['.bin']; |
94 | | - const linters = [ |
95 | | - '.eslintrc', |
96 | | - '.eslintrc.js', |
97 | | - '.eslintrc.yml', |
98 | | - '.prettierrc', |
99 | | - '.jshintrc', |
100 | | - '.babelrc', |
101 | | - '.jscs.json', |
102 | | - '.lint', |
103 | | - ]; |
104 | | - const hints = ['*.flow', '*.webidl', '*.map', '@types']; |
105 | | - const scripts = [ |
106 | | - '*.sh', |
107 | | - '*.bat', |
108 | | - '*.exe', |
109 | | - 'Gruntfile.js', |
110 | | - 'gulpfile.js', |
111 | | - 'Makefile', |
112 | | - ]; |
113 | | - const untranspiledSources = ['*.coffee', '*.scss', '*.sass', '.ts', '.tsx']; |
114 | | - const editors = ['.editorconfig', '.vscode']; |
115 | | - const git = [ |
116 | | - '.gitattributes', |
117 | | - '.gitkeep', |
118 | | - '.gitempty', |
119 | | - '.gitmodules', |
120 | | - '.keep', |
121 | | - '.empty', |
122 | | - ]; |
123 | | - const ci = [ |
124 | | - '.travis.yml', |
125 | | - '.coveralls.yml', |
126 | | - '.instanbul.yml', |
127 | | - 'appveyor.yml', |
128 | | - '.zuul.yml', |
129 | | - ]; |
130 | | - const meta = [ |
131 | | - 'package-lock.json', |
132 | | - 'component.json', |
133 | | - 'bower.json', |
134 | | - 'yarn.lock', |
135 | | - ]; |
136 | | - const misc = ['.*ignore', '.DS_Store', 'Dockerfile', 'docker-compose.yml']; |
137 | | - |
138 | | - await deleteFromNodeModules(tests); |
139 | | - await deleteFromNodeModules(docs); |
140 | | - await deleteFromNodeModules(examples); |
141 | | - await deleteFromNodeModules(bins); |
142 | | - await deleteFromNodeModules(linters); |
143 | | - await deleteFromNodeModules(hints); |
144 | | - await deleteFromNodeModules(scripts); |
145 | | - await deleteFromNodeModules(untranspiledSources); |
146 | | - await deleteFromNodeModules(editors); |
147 | | - await deleteFromNodeModules(git); |
148 | | - await deleteFromNodeModules(ci); |
149 | | - await deleteFromNodeModules(meta); |
150 | | - await deleteFromNodeModules(misc); |
| 73 | + log.info('Deleted %d files', await scanDelete({ |
| 74 | + directory: build.resolvePath('node_modules'), |
| 75 | + regularExpressions: makeRegexps([ |
| 76 | + // tests |
| 77 | + '**/test', |
| 78 | + '**/tests', |
| 79 | + '**/__tests__', |
| 80 | + '**/mocha.opts', |
| 81 | + '**/*.test.js', |
| 82 | + '**/*.snap', |
| 83 | + '**/coverage', |
| 84 | + |
| 85 | + // docs |
| 86 | + '**/doc', |
| 87 | + '**/docs', |
| 88 | + '**/CONTRIBUTING.md', |
| 89 | + '**/Contributing.md', |
| 90 | + '**/contributing.md', |
| 91 | + '**/History.md', |
| 92 | + '**/HISTORY.md', |
| 93 | + '**/history.md', |
| 94 | + '**/CHANGELOG.md', |
| 95 | + '**/Changelog.md', |
| 96 | + '**/changelog.md', |
| 97 | + |
| 98 | + // examples |
| 99 | + '**/example', |
| 100 | + '**/examples', |
| 101 | + '**/demo', |
| 102 | + '**/samples', |
| 103 | + |
| 104 | + // bins |
| 105 | + '**/.bin', |
| 106 | + |
| 107 | + // linters |
| 108 | + '**/.eslintrc', |
| 109 | + '**/.eslintrc.js', |
| 110 | + '**/.eslintrc.yml', |
| 111 | + '**/.prettierrc', |
| 112 | + '**/.jshintrc', |
| 113 | + '**/.babelrc', |
| 114 | + '**/.jscs.json', |
| 115 | + '**/.lint', |
| 116 | + |
| 117 | + // hints |
| 118 | + '**/*.flow', |
| 119 | + '**/*.webidl', |
| 120 | + '**/*.map', |
| 121 | + '**/@types', |
| 122 | + |
| 123 | + // scripts |
| 124 | + '**/*.sh', |
| 125 | + '**/*.bat', |
| 126 | + '**/*.exe', |
| 127 | + '**/Gruntfile.js', |
| 128 | + '**/gulpfile.js', |
| 129 | + '**/Makefile', |
| 130 | + |
| 131 | + // untranspiled sources |
| 132 | + '**/*.coffee', |
| 133 | + '**/*.scss', |
| 134 | + '**/*.sass', |
| 135 | + '**/.ts', |
| 136 | + '**/.tsx', |
| 137 | + |
| 138 | + // editors |
| 139 | + '**/.editorconfig', |
| 140 | + '**/.vscode', |
| 141 | + |
| 142 | + // git |
| 143 | + '**/.gitattributes', |
| 144 | + '**/.gitkeep', |
| 145 | + '**/.gitempty', |
| 146 | + '**/.gitmodules', |
| 147 | + '**/.keep', |
| 148 | + '**/.empty', |
| 149 | + |
| 150 | + // ci |
| 151 | + '**/.travis.yml', |
| 152 | + '**/.coveralls.yml', |
| 153 | + '**/.instanbul.yml', |
| 154 | + '**/appveyor.yml', |
| 155 | + '**/.zuul.yml', |
| 156 | + |
| 157 | + // metadata |
| 158 | + '**/package-lock.json', |
| 159 | + '**/component.json', |
| 160 | + '**/bower.json', |
| 161 | + '**/yarn.lock', |
| 162 | + |
| 163 | + // misc |
| 164 | + '**/.*ignore', |
| 165 | + '**/.DS_Store', |
| 166 | + '**/Dockerfile', |
| 167 | + '**/docker-compose.yml' |
| 168 | + ]) |
| 169 | + })); |
151 | 170 | }, |
152 | 171 | }; |
153 | 172 |
|
|
0 commit comments