Skip to content

Commit

Permalink
improve mount script spec matching
Browse files Browse the repository at this point in the history
  • Loading branch information
FredKSchott committed Jun 3, 2020
1 parent 0f41e5b commit 1e6852d
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,17 @@ export async function clearCache() {
* `mount src --to /_dist_` does not match `package/components/Button`
*/
export function findMatchingMountScript(scripts: BuildScript[], spec: string) {
// Only match bare module specifiers. relative and absolute imports should not match
if (
spec.startsWith('./') ||
spec.startsWith('../') ||
spec.startsWith('/') ||
spec.startsWith('http://') ||
spec.startsWith('https://')
) {
return null;
}
return scripts
.filter((script) => script.type === 'mount' && script.args.toUrl !== '/')
.filter((script) => script.type === 'mount')
.find(({args}) => spec.startsWith(args.fromDisk));
}

0 comments on commit 1e6852d

Please sign in to comment.