(filename, arch)
| 200 | |
| 201 | // filename, arch -> SourceClassification |
| 202 | classifyFilename(filename, arch) { |
| 203 | // First check to see if a plugin registered for this exact filename. |
| 204 | if (this._byFilename.hasOwnProperty(filename)) { |
| 205 | return new SourceClassification('filename', { |
| 206 | arch, |
| 207 | sourceProcessors: this._byFilename[filename].slice() |
| 208 | }); |
| 209 | } |
| 210 | |
| 211 | if (filename === ".meteorignore") { |
| 212 | return new SourceClassification("meteor-ignore"); |
| 213 | } |
| 214 | |
| 215 | // Now check to see if a plugin registered for an extension. We prefer |
| 216 | // longer extensions. |
| 217 | const parts = filename.split('.'); |
| 218 | // don't use iteration functions, so we can return (and start at #1) |
| 219 | for (let i = 1; i < parts.length; i++) { |
| 220 | const extension = parts.slice(i).join('.'); |
| 221 | |
| 222 | if (this._byExtension.hasOwnProperty(extension)) { |
| 223 | return new SourceClassification('extension', { |
| 224 | arch, |
| 225 | extension, |
| 226 | sourceProcessors: this._byExtension[extension] |
| 227 | }); |
| 228 | } |
| 229 | |
| 230 | if (this._hardcodeJs && extension === 'js') { |
| 231 | // If there is no special sourceProcessor for handling a .js file, |
| 232 | // we can still classify it as extension/js, only without any |
| 233 | // source processors. #HardcodeJs |
| 234 | return new SourceClassification('extension', { |
| 235 | extension, |
| 236 | usesDefaultSourceProcessor: true |
| 237 | }); |
| 238 | } |
| 239 | |
| 240 | if (this._legacyHandlers.hasOwnProperty(extension)) { |
| 241 | const legacy = this._legacyHandlers[extension]; |
| 242 | if (legacy.archMatching && |
| 243 | ! archinfo.matches(arch, legacy.archMatching)) { |
| 244 | return new SourceClassification('wrong-arch'); |
| 245 | } |
| 246 | return new SourceClassification('legacy-handler', { |
| 247 | extension, |
| 248 | legacyHandler: legacy.handler, |
| 249 | legacyIsTemplate: legacy.isTemplate |
| 250 | }); |
| 251 | } |
| 252 | } |
| 253 | |
| 254 | // Nothing matches; it must be a static asset (or a non-linted file). |
| 255 | return new SourceClassification('unmatched'); |
| 256 | } |
| 257 | |
| 258 | isEmpty() { |
| 259 | return _.isEmpty(this._byFilename) && _.isEmpty(this._byExtension) && |
no test coverage detected