Skip to content

Commit

Permalink
webpack-reporter: [chore][patch] fix eslint, update .npmignore (#367)
Browse files Browse the repository at this point in the history
  • Loading branch information
jchip authored Jun 13, 2017
1 parent 0f6d3bd commit d707517
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 49 deletions.
1 change: 1 addition & 0 deletions packages/electrode-webpack-reporter/.npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@
/.npmignore
/.travis.yml
*.log
/dist/map
96 changes: 47 additions & 49 deletions packages/electrode-webpack-reporter/src/server/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"use strict";

/* eslint-disable no-magic-numbers, no-sequences */

global.navigator = { userAgent: false };

process.on("SIGINT", () => {
Expand All @@ -8,60 +10,56 @@ process.on("SIGINT", () => {

const staticPathsDecor = require("electrode-static-paths");
const supports = require("electrode-archetype-react-app/supports");
const statsUtils = require("../../lib/stats-utils");
const electrodeServer = require("electrode-server")
const electrodeServer = require("electrode-server");
const confippet = require("electrode-confippet");
const WebpackReporter = require("../../lib/webpack-reporter");

supports.load()
.then(() => electrodeServer(confippet.config, [staticPathsDecor()]))
.then((server) => {

const app = {};
app.get = (path, cb) => {
server.route({
method: "GET",
path,
handler: (req, reply) => {
const res = function () { };
res.json = (data) => reply(data), res;
res.send = (data) => reply(data), res;
return cb(req, res);
}
});
};

const reporter = new WebpackReporter({
//
// When running in production mode, it means the reporter is being used as a
// module installed so can only rely on the reporter installing a route to
// serve the files from its dist directory. So skipReportRoutes should be false.
//
skipReportRoutes: process.env.NODE_ENV !== "production",
skipSocket: process.env.NODE_ENV !== "production",
socketPort: 5001
});

const reporterOptions = {
state: true,
stats: {
hasWarnings: () => true,
hasErrors: () => true,
toJson: () => require("./stats_err.json") // eslint-disable-line
},
options: {
host: "localhost",
port: 3000
supports.load().then(() => electrodeServer(confippet.config, [staticPathsDecor()])).then(server => {
const app = {};
app.get = (path, cb) => {
server.route({
method: "GET",
path,
handler: (req, reply) => {
const res = function() {};
res.json = data => (reply(data), res);
res.send = data => (reply(data), res);
return cb(req, res);
}
}

const config = {};
});
};

reporter.apply(config);
config.setup(app);
config.reporter(reporterOptions);
const reporter = new WebpackReporter({
//
// Trigger refresh event every 5 seconds
// When running in production mode, it means the reporter is being used as a
// module installed so can only rely on the reporter installing a route to
// serve the files from its dist directory. So skipReportRoutes should be false.
//
setInterval(() => config.reporter(reporterOptions), 5000);
skipReportRoutes: process.env.NODE_ENV !== "production",
skipSocket: process.env.NODE_ENV !== "production",
socketPort: 5001
});

const reporterOptions = {
state: true,
stats: {
hasWarnings: () => true,
hasErrors: () => true,
toJson: () => require("./stats_err.json") // eslint-disable-line
},
options: {
host: "localhost",
port: 3000
}
};

const config = {};

reporter.apply(config);
config.setup(app);
config.reporter(reporterOptions);
//
// Trigger refresh event every 5 seconds
//
setInterval(() => config.reporter(reporterOptions), 5000);
});

0 comments on commit d707517

Please sign in to comment.