Skip to content

Commit

Permalink
fix(cli-plugin-service): clean 'publicPath' and 'outputDir' in projec…
Browse files Browse the repository at this point in the history
…t config file
  • Loading branch information
front-end-captain committed Apr 28, 2021
1 parent e836506 commit 665824d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
Expand Up @@ -2,6 +2,6 @@ export function cleanAssetPath(path: string) {
return path.replace(/(\/{2,})/g, "/").replace(/^\/|\/$/g, "");
}

export function removeSlash(path: string) {
return path.replace(/^\/|\/$/g, "");
export function padTailSlash(path: string) {
return path.replace(/([^/])$/, "$1/");
}
Expand Up @@ -8,6 +8,7 @@ import { isObject } from "../commands/help";
import { validateProjectConfig } from "../lib/options";

import { ProjectConfig } from "../main";
import { padTailSlash, cleanAssetPath } from "./cleanAssetPath";

function requireSpecifiedConfigFile<T>(
filePath: string,
Expand Down Expand Up @@ -83,11 +84,9 @@ export function loadProjectOptions(
}

resolved.publicPath = resolved.publicPath
? resolved.publicPath.replace(/([^/])$/, "$1/")
? padTailSlash(resolved.publicPath)
: resolved.publicPath;
resolved.outputDir = resolved.outputDir
? resolved.outputDir.replace(/^\/|\/$/g, "")
: resolved.outputDir;
resolved.outputDir = resolved.outputDir ? cleanAssetPath(resolved.outputDir) : resolved.outputDir;

validateProjectConfig(resolved, (msg) => {
error(`Invalid options in ${chalk.bold(configFilename)}: ${msg}`);
Expand Down

0 comments on commit 665824d

Please sign in to comment.