Applied coding styles to config files

This commit is contained in:
Alejandro Celaya
2018-08-26 00:00:53 +02:00
parent 4e67798746
commit fff18202fd
9 changed files with 635 additions and 544 deletions

View File

@@ -1,4 +1,3 @@
'use strict';
const path = require('path');
const fs = require('fs');
@@ -7,22 +6,23 @@ const url = require('url');
// Make sure any symlinks in the project folder are resolved:
// https://github.com/facebookincubator/create-react-app/issues/637
const appDirectory = fs.realpathSync(process.cwd());
const resolveApp = relativePath => path.resolve(appDirectory, relativePath);
const resolveApp = (relativePath) => path.resolve(appDirectory, relativePath);
const envPublicUrl = process.env.PUBLIC_URL;
function ensureSlash(path, needsSlash) {
const hasSlash = path.endsWith('/');
if (hasSlash && !needsSlash) {
return path.substr(path, path.length - 1);
} else if (!hasSlash && needsSlash) {
return `${path}/`;
} else {
return path;
}
return path;
}
const getPublicUrl = appPackageJson =>
const getPublicUrl = (appPackageJson) =>
envPublicUrl || require(appPackageJson).homepage;
// We use `PUBLIC_URL` environment variable or "homepage" field to infer
@@ -34,6 +34,7 @@ const getPublicUrl = appPackageJson =>
function getServedPath(appPackageJson) {
const publicUrl = getPublicUrl(appPackageJson);
const servedUrl = envPublicUrl || (publicUrl ? url.parse(publicUrl).pathname : '/');
return ensureSlash(servedUrl, true);
}