Skip to content

Commit 9dadfdd

Browse files
committed
Change getFilePath to use Node's path library
Previous code used explicit path slash to determine the folder path of a file, which only works if the OS in question uses that type of slash. Node's path library is OS-agnostic and avoids these issues.
1 parent c1e00f2 commit 9dadfdd

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/helpers/getClasses.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import sass from 'sass';
44
import { extractICSS } from 'icss-utils';
55
import { Logger } from './logger';
66
import { Options, CustomRenderer } from '../options';
7+
import path from "path";
78

89
export const enum FileTypes {
910
css = 'css',
@@ -17,8 +18,7 @@ export const getFileType = (fileName: string) => {
1718
return FileTypes.scss;
1819
};
1920

20-
const getFilePath = (fileName: string) =>
21-
fileName.substring(0, fileName.lastIndexOf('/'));
21+
const getFilePath = (fileName: string) => path.dirname(fileName);
2222

2323
export const getClasses = (
2424
processor: postcss.Processor,
@@ -71,7 +71,7 @@ export const getClasses = (
7171

7272
return processedCss.root ? extractICSS(processedCss.root).icssExports : {};
7373
} catch (e) {
74-
console.log(e);
74+
logger.log(e);
7575
logger.error(e);
7676
return {};
7777
}

0 commit comments

Comments
 (0)