Skip to content

Commit 129348b

Browse files
authored
[mercury] Avoid requiring sass to use the CLI and create --outDir with recursive (#435)
* Create dir with recursive * Avoid requiring sass to use the CLI
1 parent 1698391 commit 129348b

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

packages/mercury/src/cli/internal/file-management.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export const ensureDirectoryExistsAndItsClear = (dirPath: string) => {
88
fs.rmSync(dirPath, { recursive: true });
99
}
1010

11-
fs.mkdirSync(dirPath);
11+
fs.mkdirSync(dirPath, { recursive: true });
1212
};
1313

1414
export function* walkSync(dir: string): Generator<FileMetadata> {

packages/mercury/src/cli/internal/transpile-bundle-and-create-mappings.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import fs from "node:fs";
22
import path from "node:path";
3+
import * as sass from "sass";
34

45
import {
56
BASE_BUNDLE_WITH_BACK_SLASH,
@@ -19,11 +20,16 @@ import {
1920
import { BundleMetadata, FileMetadata } from "./types.js";
2021
import {
2122
getBundleNameWithoutSpecialChars,
22-
replacePlaceholdersInBundle,
23-
transpileBundle
23+
replacePlaceholdersInBundle
2424
} from "./utils.js";
2525
import { printBundleWasTranspiled } from "./print-utils.js";
2626

27+
const transpileBundle = (filePath: string, globant: boolean) =>
28+
sass.compile(filePath, {
29+
loadPaths: [globant ? "src/config/globant" : "src/config/default"],
30+
style: "compressed"
31+
}).css;
32+
2733
const CSS_CREATED_DIRS = new Set();
2834
const JS_CREATED_DIRS = new Set();
2935
const BUNDLES: BundleMetadata[] = [];

packages/mercury/src/cli/internal/utils.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import crypto from "node:crypto";
22
import { styleText } from "node:util";
3-
import * as sass from "sass";
43

54
import {
65
FONT_FACE_PATH_PLACEHOLDER,
@@ -29,12 +28,6 @@ export const getFileSize = (fileContent: string) => {
2928
return fileLengthInGB.toFixed(3) + "GB";
3029
};
3130

32-
export const transpileBundle = (filePath: string, globant: boolean) =>
33-
sass.compile(filePath, {
34-
loadPaths: [globant ? "src/config/globant" : "src/config/default"],
35-
style: "compressed"
36-
}).css;
37-
3831
export const getHash = (fileContent: string) =>
3932
crypto.createHash("md5").update(fileContent).digest("hex").substring(16);
4033

0 commit comments

Comments
 (0)