Skip to content

Commit

Permalink
fix(replace): do not transform code if no values are given (#17)
Browse files Browse the repository at this point in the history
* replace: do not transfrom code is no values are given

Fixes #16

* add test

* npm test
  • Loading branch information
ashi009 authored and shellscape committed Oct 31, 2019
1 parent afe9bac commit cec516f
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 0 deletions.
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.

0 comments on commit cec516f

Please sign in to comment.