This repository has been archived by the owner on Sep 28, 2020. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Stop Fixing if there are no fixable errors or warnings * Update README.md * Added Tests for infinte loop * Fix Typo
- Loading branch information
1 parent
7108379
commit 7040248
Showing
4 changed files
with
63 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
var fs = require("fs"); | ||
|
||
var test = require("ava"); | ||
var webpack = require("webpack"); | ||
|
||
var conf = require("./utils/conf"); | ||
|
||
var changed = false; | ||
|
||
// clone the "fixable" file, so that we do not lose the original contents | ||
// when the fixes are applied to disk | ||
test.before(function() { | ||
fs.createReadStream("./test/fixtures/nonfixable.js") | ||
.pipe(fs.createWriteStream("./test/fixtures/nonfixable-clone.js")) | ||
.on("close", function() { | ||
fs.watch("./test/fixtures/nonfixable-clone.js", function() { | ||
changed = true; | ||
}); | ||
}); | ||
}); | ||
|
||
test.cb("loader shouldn't change file if there are no fixable errors/warnings", function( | ||
t | ||
) { | ||
t.plan(1); | ||
webpack( | ||
conf({ | ||
entry: "./test/fixtures/nonfixable-clone.js", | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.js$/, | ||
use: "./index?fix=true", | ||
exclude: /node_modules/ | ||
} | ||
] | ||
} | ||
}), | ||
function(err) { | ||
if (err) { | ||
throw err; | ||
} | ||
// console.log(stats.compilation.errors) | ||
t.false( | ||
changed, | ||
"should not output to file again (triggering a recompile)" | ||
); | ||
t.end(); | ||
} | ||
); | ||
}); | ||
|
||
// remove the clone | ||
test.after.always(function() { | ||
fs.unlinkSync("./test/fixtures/nonfixable-clone.js"); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
function foo() { | ||
return stuff; | ||
} | ||
|
||
foo(); |