Skip to content

Commit 217a8e9

Browse files
committed
Don't try to replace imports or log if there weren't any changes
1 parent 5b4ae9c commit 217a8e9

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

index.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,14 @@ const createModuleResolverPreprocessor = (karmaConfig, args = {}, config = {}, l
7272
// Imports can only be at top level as per specification
7373
if (node.type === 'ImportDeclaration' && node.source.type === 'Literal') {
7474
const resolved = resolvePath(node.source.value, file);
75-
const replacement = node.source.raw.replace(node.source.value, resolved);
76-
log.debug('Replacing import from "%s" with "%s"', node.source.value, replacement);
77-
patchedContent =
78-
patchedContent.slice(0, node.source.start) +
79-
replacement +
80-
patchedContent.slice(node.source.end);
75+
if (resolved !== node.source.value) {
76+
const replacement = node.source.raw.replace(node.source.value, resolved);
77+
log.debug('Replacing import from "%s" with "%s"', node.source.value, resolved);
78+
patchedContent =
79+
patchedContent.slice(0, node.source.start) +
80+
replacement +
81+
patchedContent.slice(node.source.end);
82+
}
8183
}
8284
}
8385

0 commit comments

Comments
 (0)