Skip to content

Commit

Permalink
fixes --cache and --no-cache
Browse files Browse the repository at this point in the history
  • Loading branch information
sokra committed Dec 7, 2016
1 parent 73886d5 commit 5225c00
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 12 deletions.
2 changes: 1 addition & 1 deletion bin/config-yargs.js
Expand Up @@ -144,7 +144,7 @@ module.exports = function(yargs) {
"cache": {
type: "boolean",
describe: "Enable in memory caching",
default: true,
default: null,
group: ADVANCED_GROUP,
defaultDescription: "It's enabled by default when watching"
},
Expand Down
15 changes: 5 additions & 10 deletions bin/convert-argv.js
Expand Up @@ -188,7 +188,7 @@ module.exports = function(yargs, argv, convertOptions) {
if(finalize) {
finalize();
}
} else if(typeof argv[name] !== "undefined") {
} else if(typeof argv[name] !== "undefined" && argv[name] !== null) {
if(init) {
init();
}
Expand Down Expand Up @@ -219,16 +219,11 @@ module.exports = function(yargs, argv, convertOptions) {
}

function mapArgToBoolean(name, optionName) {
ifBooleanArg(name, function() {
options[optionName || name] = true;
});
}

function mapArgToBooleanInverse(name, optionName) {
ifArg(name, function(bool) {
if(!bool) {
if(bool === true)
options[optionName || name] = true;
else if(bool === false)
options[optionName || name] = false;
}
});
}

Expand Down Expand Up @@ -388,7 +383,7 @@ module.exports = function(yargs, argv, convertOptions) {
options.target = value;
});

mapArgToBooleanInverse("cache");
mapArgToBoolean("cache");

ifBooleanArg("hot", function() {
ensureArray(options, "plugins");
Expand Down
2 changes: 1 addition & 1 deletion lib/WebpackOptionsApply.js
Expand Up @@ -270,7 +270,7 @@ WebpackOptionsApply.prototype.process = function(options, compiler) {

compiler.apply(new WarnCaseSensitiveModulesPlugin());

if(options.cache === undefined ? options.watch : options.cache) {
if(options.cache) {
var CachePlugin = require("./CachePlugin");
compiler.apply(new CachePlugin(typeof options.cache === "object" ? options.cache : null));
}
Expand Down

0 comments on commit 5225c00

Please sign in to comment.