Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replace: do not transform code if no values are given #17

Merged
merged 3 commits into from
Oct 31, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/replace/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export default function replace(options = {}) {
name: 'replace',

transform(code, id) {
if (!keys.length) return null;
if (!filter(id)) return null;

const magicString = new MagicString(code);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
description: 'replaces nothing',
options: { }
};
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
console.log('as-it'); // eslint-disable-line
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
console.log('as-it');
6 changes: 6 additions & 0 deletions packages/replace/test/snapshots/form.js.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,9 @@ Generated by [AVA](https://ava.li).
`const one = 1; // eslint-disable-line␊
console.log(one);`

## replace-nothing: replaces nothing

> Snapshot 1

'console.log(\'as-it\'); // eslint-disable-line'
Binary file modified packages/replace/test/snapshots/form.js.snap
Binary file not shown.