Skip to content

Commit

Permalink
normalize paths in printed config
Browse files Browse the repository at this point in the history
  • Loading branch information
maddsua committed Sep 12, 2024
1 parent 0b2e21d commit 8dea614
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
6 changes: 2 additions & 4 deletions cli/assets.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { readdirSync, existsSync, mkdirSync, createReadStream, statSync } from 'fs';
import { createHash } from 'crypto';
import { join, basename, resolve, extname, dirname } from 'path';
import { normalizePath } from './utils';

export interface AssetFile {
slug: string;
Expand Down Expand Up @@ -42,10 +43,7 @@ export const findAssets = async (assetDir: string, cacheDir: string): Promise<As

return entries.map(item => {

const slug = resolve(item)
.slice(assetDirResolved.length)
.replace(/[\\\/]+/g, '/');

const slug = normalizePath(resolve(item).slice(assetDirResolved.length));
const ext = extname(slug);

return {
Expand Down
5 changes: 3 additions & 2 deletions cli/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { outputOptions, imageFormats } from './formats';
import { existsSync, rmSync } from 'fs';
import { clearUnusedCache, copyStaticAssets, transformImageAssets, type InvocationStats } from './operations';
import type { RuntimeConfig } from "./config";
import { normalizePath } from "./utils";

const main = async () => {

Expand Down Expand Up @@ -164,8 +165,8 @@ const printCliConfig = (config: RuntimeConfig) => {

const entries: [string, string][] = [
['Cache', config.noCache ? 'disabled' : 'enabled'],
['Load from', `"${config.inputDir}"`],
['Save to', `"${config.outputDir}"`],
['Load from', `"${normalizePath(config.inputDir)}"`],
['Save to', `"${normalizePath(config.outputDir)}"`],
['Output formats', Object.keys(config.outputFormats).join(',')],
];

Expand Down
2 changes: 2 additions & 0 deletions cli/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ export const splitChunks = <T>(items: T[], size: number): T[][] => {

return result;
};

export const normalizePath = (path: string): string => path.replace(/[\\\/]+/g, '/');

0 comments on commit 8dea614

Please sign in to comment.