Throw error when output.filename is missing

#719
This commit is contained in:
Tobias Koppers 2015-03-05 22:21:47 +01:00
parent aa7885b91d
commit b31a8110b3
1 changed files with 5 additions and 0 deletions

View File

@ -25,12 +25,15 @@ module.exports = function(optimist, argv, convertOptions) {
argv["optimize-minimize"] = true; argv["optimize-minimize"] = true;
} }
var configFileLoaded = false;
if(argv.config) { if(argv.config) {
options = require(path.resolve(argv.config)); options = require(path.resolve(argv.config));
configFileLoaded = true;
} else { } else {
var configPath = path.resolve("webpack.config.js"); var configPath = path.resolve("webpack.config.js");
if(fs.existsSync(configPath)) { if(fs.existsSync(configPath)) {
options = require(configPath); options = require(configPath);
configFileLoaded = true;
} }
} }
if(typeof options !== "object" || options === null) { if(typeof options !== "object" || options === null) {
@ -405,6 +408,8 @@ module.exports = function(optimist, argv, convertOptions) {
options.output.filename = argv._.pop(); options.output.filename = argv._.pop();
options.output.path = path.dirname(options.output.filename); options.output.path = path.dirname(options.output.filename);
options.output.filename = path.basename(options.output.filename); options.output.filename = path.basename(options.output.filename);
} else if(configFileLoaded) {
throw new Error("'output.filename' is required, either in config file or as --output-file");
} else { } else {
optimist.showHelp(); optimist.showHelp();
process.exit(-1); process.exit(-1);