(targetPath: string)
| 144 | // - /[param1]/[param2]/[param3].csv |
| 145 | // - /[param1]/[param2]/[param3].csv.js |
| 146 | private findFile(targetPath: string): Loader | undefined { |
| 147 | const ext = extname(targetPath); |
| 148 | const exts = ext ? [ext, ...Array.from(this.interpreters.keys(), (iext) => ext + iext)] : [ext]; |
| 149 | const found = route(this.root, ext ? targetPath.slice(0, -ext.length) : targetPath, exts); |
| 150 | if (!found) return; |
| 151 | const {path, params, ext: fext} = found; |
| 152 | if (fext === ext) return new StaticLoader({root: this.root, path, params}); |
| 153 | const commandPath = join(this.root, path); |
| 154 | const [command, ...args] = this.interpreters.get(fext.slice(ext.length))!; |
| 155 | if (command != null) args.push(commandPath); |
| 156 | return new CommandLoader({ |
| 157 | command: command ?? commandPath, |
| 158 | args: params ? args.concat(defineParams(params)) : args, |
| 159 | path, |
| 160 | params, |
| 161 | root: this.root, |
| 162 | targetPath |
| 163 | }); |
| 164 | } |
| 165 | |
| 166 | // Finding a file in an archive: |
| 167 | // - /path/to.zip |
no test coverage detected