From 34efce9c44ed2fd8414da77089e04f055405d361 Mon Sep 17 00:00:00 2001 From: Eric Peterson Date: Mon, 12 Jul 2021 13:03:18 +0200 Subject: [PATCH] Apply helper to local, just to be consistent. Signed-off-by: Eric Peterson --- .../src/stages/publish/local.ts | 26 +++++-------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/packages/techdocs-common/src/stages/publish/local.ts b/packages/techdocs-common/src/stages/publish/local.ts index 9bbc02e34f..3414d273dd 100644 --- a/packages/techdocs-common/src/stages/publish/local.ts +++ b/packages/techdocs-common/src/stages/publish/local.ts @@ -32,7 +32,11 @@ import { ReadinessResponse, TechDocsMetadata, } from './types'; -import { getFileTreeRecursively, getHeadersForFileExtension } from './helpers'; +import { + getFileTreeRecursively, + getHeadersForFileExtension, + lowerCaseEntityTripletInStoragePath, +} from './helpers'; // TODO: Use a more persistent storage than node_modules or /tmp directory. // Make it configurable with techdocs.publisher.local.publishDirectory @@ -182,30 +186,14 @@ export class LocalPublish implements PublisherBase { files.map(f => limit(async file => { const relativeFile = file.replace(`${staticDocsDir}${path.sep}`, ''); - const [namespace, kind, name, ...parts] = relativeFile.split( - path.sep, - ); - const lowerNamespace = namespace.toLowerCase(); - const lowerKind = kind.toLowerCase(); - const lowerName = name.toLowerCase(); + const newFile = lowerCaseEntityTripletInStoragePath(relativeFile); // If all parts are already lowercase, ignore. - if ( - namespace === lowerNamespace && - kind === lowerKind && - name === lowerName - ) { + if (relativeFile === newFile) { return; } // Otherwise, copy or move the file. - const newFile = [ - staticDocsDir, - lowerNamespace, - lowerKind, - lowerName, - ...parts, - ].join(path.sep); await new Promise(resolve => { const migrate = removeOriginal ? fs.move : fs.copyFile; this.logger.debug(`Migrating ${relativeFile}`);