mirror of https://github.com/webpack/webpack.git
				
				
				
			
		
			
				
	
	
		
			31 lines
		
	
	
		
			671 B
		
	
	
	
		
			JavaScript
		
	
	
	
			
		
		
	
	
			31 lines
		
	
	
		
			671 B
		
	
	
	
		
			JavaScript
		
	
	
	
| "use strict";
 | |
| 
 | |
| const handleExport = options => {
 | |
| 	const isES6DefaultExported =
 | |
| 		typeof options === "object" &&
 | |
| 		options !== null &&
 | |
| 		typeof options.default !== "undefined";
 | |
| 	options = isES6DefaultExported ? options.default : options;
 | |
| 	return options;
 | |
| };
 | |
| 
 | |
| const handleFunction = (options, argv) => {
 | |
| 	if (typeof options === "function") {
 | |
| 		options = options(argv.env, argv);
 | |
| 	}
 | |
| 	return options;
 | |
| };
 | |
| 
 | |
| module.exports = (options, argv) => {
 | |
| 	argv = argv || {};
 | |
| 
 | |
| 	options = handleExport(options);
 | |
| 
 | |
| 	if (Array.isArray(options)) {
 | |
| 		options = options.map(_options => handleFunction(_options, argv));
 | |
| 	} else {
 | |
| 		options = handleFunction(options, argv);
 | |
| 	}
 | |
| 	return options;
 | |
| };
 |