forked from webpack/webpack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExamples.test.js
More file actions
37 lines (35 loc) · 1.19 KB
/
Examples.test.js
File metadata and controls
37 lines (35 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
var should = require("should");
var path = require("path");
var fs = require("fs");
var webpack = require("../");
describe("Examples", function() {
var examples = fs.readdirSync(path.join(__dirname, "..", "examples")).map(function(name) {
return path.join(__dirname, "..", "examples", name);
}).filter(function(p) {
return fs.statSync(p).isDirectory();
});
examples.forEach(function(examplePath) {
it("should compile " + path.basename(examplePath), function(done) {
var options = {};
if(fs.existsSync(path.join(examplePath, "webpack.config.js")))
options = require(path.join(examplePath, "webpack.config.js"));
options.context = examplePath;
options.optimize = options.optimize || {};
options.output = options.output || {};
options.optimize.occurenceOrder = true;
options.output.pathInfo = true;
options.output.path = path.join(examplePath, "js")
if(!options.output.filename)
options.output.filename = "output.js";
if(!options.entry)
options.entry = "./example.js";
webpack(options, function(err, stats) {
if(err) return done(err);
stats = stats.toJson();
if(stats.errors.length > 0)
return done(stats.errors[0]);
done();
});
});
});
});