From f9599a58017cf27a219c00ddb56f678175e58b41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20C=C3=A1mera?= Date: Wed, 15 Jan 2025 14:01:52 -0300 Subject: [PATCH 1/2] Create dir with recursive --- packages/mercury/src/cli/internal/file-management.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/mercury/src/cli/internal/file-management.ts b/packages/mercury/src/cli/internal/file-management.ts index 25bfde007..617302afd 100644 --- a/packages/mercury/src/cli/internal/file-management.ts +++ b/packages/mercury/src/cli/internal/file-management.ts @@ -8,7 +8,7 @@ export const ensureDirectoryExistsAndItsClear = (dirPath: string) => { fs.rmSync(dirPath, { recursive: true }); } - fs.mkdirSync(dirPath); + fs.mkdirSync(dirPath, { recursive: true }); }; export function* walkSync(dir: string): Generator { From 804290ffe2a168de71b9e5d9f9338f1f52e469e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20C=C3=A1mera?= Date: Wed, 15 Jan 2025 14:05:37 -0300 Subject: [PATCH 2/2] Avoid requiring sass to use the CLI --- .../internal/transpile-bundle-and-create-mappings.ts | 10 ++++++++-- packages/mercury/src/cli/internal/utils.ts | 7 ------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/packages/mercury/src/cli/internal/transpile-bundle-and-create-mappings.ts b/packages/mercury/src/cli/internal/transpile-bundle-and-create-mappings.ts index 47ff212cd..fa37f801a 100644 --- a/packages/mercury/src/cli/internal/transpile-bundle-and-create-mappings.ts +++ b/packages/mercury/src/cli/internal/transpile-bundle-and-create-mappings.ts @@ -1,5 +1,6 @@ import fs from "node:fs"; import path from "node:path"; +import * as sass from "sass"; import { BASE_BUNDLE_WITH_BACK_SLASH, @@ -19,11 +20,16 @@ import { import { BundleMetadata, FileMetadata } from "./types.js"; import { getBundleNameWithoutSpecialChars, - replacePlaceholdersInBundle, - transpileBundle + replacePlaceholdersInBundle } from "./utils.js"; import { printBundleWasTranspiled } from "./print-utils.js"; +const transpileBundle = (filePath: string, globant: boolean) => + sass.compile(filePath, { + loadPaths: [globant ? "src/config/globant" : "src/config/default"], + style: "compressed" + }).css; + const CSS_CREATED_DIRS = new Set(); const JS_CREATED_DIRS = new Set(); const BUNDLES: BundleMetadata[] = []; diff --git a/packages/mercury/src/cli/internal/utils.ts b/packages/mercury/src/cli/internal/utils.ts index 9cffad74f..0a7f89a30 100644 --- a/packages/mercury/src/cli/internal/utils.ts +++ b/packages/mercury/src/cli/internal/utils.ts @@ -1,6 +1,5 @@ import crypto from "node:crypto"; import { styleText } from "node:util"; -import * as sass from "sass"; import { FONT_FACE_PATH_PLACEHOLDER, @@ -29,12 +28,6 @@ export const getFileSize = (fileContent: string) => { return fileLengthInGB.toFixed(3) + "GB"; }; -export const transpileBundle = (filePath: string, globant: boolean) => - sass.compile(filePath, { - loadPaths: [globant ? "src/config/globant" : "src/config/default"], - style: "compressed" - }).css; - export const getHash = (fileContent: string) => crypto.createHash("md5").update(fileContent).digest("hex").substring(16);