@pronto-tools-and-more/sass-compiler 3.3.13 → 3.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pronto-tools-and-more/sass-compiler",
3
- "version": "3.3.13",
3
+ "version": "3.4.0",
4
4
  "description": "",
5
5
  "main": "src/sassCompilerMain.js",
6
6
  "type": "module",
@@ -4,8 +4,10 @@ import { dirname, join } from "node:path";
4
4
  import * as Assert from "../Assert/Assert.js";
5
5
  import * as CompileSass from "../CompileSass/CompileSass.js";
6
6
  import * as InMemoryFileState from "../InMemoryFileState/InMemoryFileState.js";
7
+ import { existsSync } from "node:fs";
7
8
 
8
- const getIndividualFileNames = (contents) => {
9
+ const getIndividualFileNames = (rootScssFileName, contents) => {
10
+ const rootDirName = dirname(rootScssFileName);
9
11
  const lines = contents.split("\n");
10
12
  const individualFileNames = [];
11
13
  for (const line of lines) {
@@ -14,7 +16,15 @@ const getIndividualFileNames = (contents) => {
14
16
  if (match.endsWith(".scss")) {
15
17
  individualFileNames.push(match);
16
18
  } else {
17
- individualFileNames.push(match + ".scss");
19
+ const fileName1 = match + ".scss";
20
+ const fileName2 = match + ".css";
21
+ const absolutePath1 = join(rootDirName, fileName1);
22
+ const absolutePath2 = join(rootDirName, fileName2);
23
+ if (existsSync(absolutePath1)) {
24
+ individualFileNames.push(fileName1);
25
+ } else if (existsSync(absolutePath2)) {
26
+ individualFileNames.push(fileName2);
27
+ }
18
28
  }
19
29
  }
20
30
  }
@@ -30,7 +40,6 @@ const getFileNamesToUpdate = (
30
40
  if (needsFull || !fileName) {
31
41
  return individualFileNames;
32
42
  }
33
- // console.log({ individualFileNames, fileName });
34
43
  for (const individualFileName of individualFileNames) {
35
44
  const absolutePath = join(dirname(rootScssFileName), individualFileName);
36
45
  if (absolutePath === fileName) {
@@ -56,7 +65,10 @@ export const compileSassIndividually = async (
56
65
  InMemoryFileState.set(fileName, content);
57
66
  }
58
67
  const contents = await readFile(rootScssFileName, "utf8");
59
- const individualFileNames = getIndividualFileNames(contents);
68
+ const individualFileNames = getIndividualFileNames(
69
+ rootScssFileName,
70
+ contents
71
+ );
60
72
  const toUpdate = getFileNamesToUpdate(
61
73
  individualFileNames,
62
74
  rootScssFileName,