Skip to content

Commit

Permalink
refactor(server): switch update options to normalize options
Browse files Browse the repository at this point in the history
  • Loading branch information
knagaitsev committed Jul 23, 2019
1 parent d19861d commit b4fd742
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions lib/Server.js
Expand Up @@ -24,7 +24,7 @@ const webpack = require('webpack');
const webpackDevMiddleware = require('webpack-dev-middleware');
const validateOptions = require('schema-utils');
const isAbsoluteUrl = require('is-absolute-url');
const updateOptions = require('./utils/updateOptions');
const normalizeOptions = require('./utils/normalizeOptions');
const updateCompiler = require('./utils/updateCompiler');
const createLogger = require('./utils/createLogger');
const getCertificate = require('./utils/getCertificate');
Expand Down Expand Up @@ -73,7 +73,7 @@ class Server {
);
}

updateOptions(this.compiler, this.options);
normalizeOptions(this.compiler, this.options);

updateCompiler(this.compiler, this.options);

Expand Down
4 changes: 2 additions & 2 deletions lib/utils/updateOptions.js → lib/utils/normalizeOptions.js
Expand Up @@ -4,7 +4,7 @@
no-undefined
*/

function updateOptions(compiler, options) {
function normalizeOptions(compiler, options) {
// Setup default value
options.contentBase =
options.contentBase !== undefined ? options.contentBase : process.cwd();
Expand All @@ -24,4 +24,4 @@ function updateOptions(compiler, options) {
}
}

module.exports = updateOptions;
module.exports = normalizeOptions;
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`updateOptions contentBase array should set correct options 1`] = `
exports[`normalizeOptions contentBase array should set correct options 1`] = `
Object {
"clientMode": "sockjs",
"contentBase": Array [
Expand All @@ -12,7 +12,7 @@ Object {
}
`;

exports[`updateOptions contentBase string should set correct options 1`] = `
exports[`normalizeOptions contentBase string should set correct options 1`] = `
Object {
"clientMode": "sockjs",
"contentBase": "/path/to/dist",
Expand All @@ -21,15 +21,15 @@ Object {
}
`;

exports[`updateOptions no options should set correct options 1`] = `
exports[`normalizeOptions no options should set correct options 1`] = `
Object {
"clientMode": "sockjs",
"serverMode": "sockjs",
"watchOptions": Object {},
}
`;

exports[`updateOptions watchOptions should set correct options 1`] = `
exports[`normalizeOptions watchOptions should set correct options 1`] = `
Object {
"clientMode": "sockjs",
"serverMode": "sockjs",
Expand Down
@@ -1,9 +1,9 @@
'use strict';

const webpack = require('webpack');
const updateOptions = require('../../../lib/utils/updateOptions');
const normalizeOptions = require('../../../lib/utils/normalizeOptions');

describe('updateOptions', () => {
describe('normalizeOptions', () => {
const cases = [
{
title: 'no options',
Expand Down Expand Up @@ -55,7 +55,7 @@ describe('updateOptions', () => {

it('should set correct options', () => {
const originalContentBase = data.options.contentBase;
updateOptions(compiler, data.options);
normalizeOptions(compiler, data.options);
if (data.optionsResults) {
expect(data.options).toEqual(data.optionsResults);
} else {
Expand Down

0 comments on commit b4fd742

Please sign in to comment.