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.
Fixed: ignore cache when eslint rules have changed (#151)
* Fixed: ignore cache when eslint rules have changed * Update cache test with new test runner
- Loading branch information
1 parent
40567da
commit c667541
Showing
3 changed files
with
73 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
var test = require("ava") | ||
var webpack = require("webpack") | ||
var conf = require("./utils/conf") | ||
var fs = require("fs") | ||
|
||
var cacheFilePath = "./node_modules/.cache/eslint-loader/data.json" | ||
|
||
test.cb("eslint-loader can cache results", function(t) { | ||
t.plan(2) | ||
webpack(conf( | ||
{ | ||
entry: "./test/fixtures/cache.js", | ||
}, | ||
{ | ||
cache: true, | ||
} | ||
), | ||
function(err) { | ||
if (err) { | ||
throw err | ||
} | ||
|
||
fs.readFile(cacheFilePath, "utf8", function(err, contents) { | ||
if (err) { | ||
t.fail("expected cache file to have been created") | ||
} | ||
else { | ||
t.pass("cache file has been created") | ||
|
||
var contentsJson = JSON.parse(contents) | ||
t.deepEqual( | ||
Object.keys(contentsJson["test/fixtures/cache.js"]), | ||
["hash", "rules", "res"], | ||
"cache values have been set for the linted file" | ||
) | ||
} | ||
|
||
t.end() | ||
|
||
}) | ||
|
||
}) | ||
}) | ||
|
||
// delete the cache file once tests have completed | ||
test.after.always("teardown", function() { | ||
fs.unlinkSync(cacheFilePath) | ||
}) |
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,7 @@ | ||
"use strict" | ||
|
||
function cacheIt() { | ||
return "cache" | ||
} | ||
|
||
cacheIt() |