sheetloaf 1.3.0 → 1.3.1-beta.2
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/dist/index.js +12 -17
- package/dist/sources.js +28 -3
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -45,13 +45,13 @@ const sass_1 = __importDefault(require("sass"));
|
|
|
45
45
|
const postcss_1 = __importDefault(require("postcss"));
|
|
46
46
|
const configs = __importStar(require("./configs"));
|
|
47
47
|
const fileFinder = __importStar(require("./fileFinder"));
|
|
48
|
+
const sources = __importStar(require("./sources"));
|
|
48
49
|
const sheetloaf = new commander_1.Command();
|
|
49
|
-
sheetloaf.version("1.3.
|
|
50
|
+
sheetloaf.version("1.3.1-beta.2", '-v, --version', 'Print the version of Sheetloaf.');
|
|
50
51
|
let usingStdin = false;
|
|
51
52
|
let postcssConfig = {
|
|
52
53
|
plugins: []
|
|
53
54
|
};
|
|
54
|
-
let sourcesChecker = [];
|
|
55
55
|
sheetloaf
|
|
56
56
|
.arguments('[sources...]')
|
|
57
57
|
.description('📃🍞 Compile Sass to CSS and transform the output using PostCSS, all in one command.')
|
|
@@ -115,15 +115,17 @@ function renderPartially(source, fileName) {
|
|
|
115
115
|
}
|
|
116
116
|
else {
|
|
117
117
|
let partialExistsInSassSources = false;
|
|
118
|
-
|
|
119
|
-
|
|
118
|
+
let ind = 0;
|
|
119
|
+
while (ind < sources.getChecker().length) {
|
|
120
|
+
const toCheck = sources.getChecker()[ind];
|
|
121
|
+
if (toCheck.containsPartial(fileName)) {
|
|
120
122
|
partialExistsInSassSources = true;
|
|
121
|
-
renderSass(
|
|
123
|
+
renderSass(toCheck.getMain());
|
|
122
124
|
}
|
|
125
|
+
ind = ind + 1;
|
|
123
126
|
}
|
|
124
127
|
if (partialExistsInSassSources === false) {
|
|
125
|
-
|
|
126
|
-
sourcesChecker.splice(0, sourcesChecker.length);
|
|
128
|
+
sources.clearSourcesChecker();
|
|
127
129
|
renderAllFiles(source);
|
|
128
130
|
}
|
|
129
131
|
}
|
|
@@ -146,7 +148,7 @@ function watch(source) {
|
|
|
146
148
|
})
|
|
147
149
|
.on('add', (added) => {
|
|
148
150
|
console.log(`File added: ${added}`);
|
|
149
|
-
|
|
151
|
+
sources.clearSourcesChecker();
|
|
150
152
|
renderAllFiles(source);
|
|
151
153
|
});
|
|
152
154
|
}
|
|
@@ -160,13 +162,13 @@ function renderSass(fileName) {
|
|
|
160
162
|
const options = configs.generateSassOptionsAsync(sheetloaf.opts());
|
|
161
163
|
const result = yield sass_1.default.compileAsync(fileName, options);
|
|
162
164
|
renderPost(fileName, destination, result);
|
|
163
|
-
addResultToSourcesChecker(fileName, result);
|
|
165
|
+
sources.addResultToSourcesChecker(fileName, result);
|
|
164
166
|
}
|
|
165
167
|
else {
|
|
166
168
|
const options = configs.generateSassOptions(sheetloaf.opts());
|
|
167
169
|
const result = sass_1.default.compile(fileName, options);
|
|
168
170
|
renderPost(fileName, destination, result);
|
|
169
|
-
addResultToSourcesChecker(fileName, result);
|
|
171
|
+
sources.addResultToSourcesChecker(fileName, result);
|
|
170
172
|
}
|
|
171
173
|
}
|
|
172
174
|
catch (e) {
|
|
@@ -308,10 +310,3 @@ function emitSassError(err) {
|
|
|
308
310
|
`;
|
|
309
311
|
return css;
|
|
310
312
|
}
|
|
311
|
-
function addResultToSourcesChecker(fileName, result) {
|
|
312
|
-
for (let i = 0; i < sourcesChecker.length; i++) {
|
|
313
|
-
if (sourcesChecker[i].getAbsoluteMain() === path_1.default.resolve(fileName)) {
|
|
314
|
-
sourcesChecker[i].setSources(result.loadedUrls);
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
}
|
package/dist/sources.js
CHANGED
|
@@ -3,8 +3,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.SassSources = void 0;
|
|
6
|
+
exports.addResultToSourcesChecker = exports.clearSourcesChecker = exports.getChecker = exports.SassSources = void 0;
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const url_1 = require("url");
|
|
9
|
+
let sourcesChecker = [];
|
|
8
10
|
class SassSources {
|
|
9
11
|
constructor(fileName, sassResult) {
|
|
10
12
|
this.sources = [];
|
|
@@ -15,8 +17,8 @@ class SassSources {
|
|
|
15
17
|
setSources(urls) {
|
|
16
18
|
this.sources.splice(0, this.sources.length);
|
|
17
19
|
urls.forEach(url => {
|
|
18
|
-
if (url.
|
|
19
|
-
this.sources.push(url.
|
|
20
|
+
if ((0, url_1.fileURLToPath)(url.href) !== this.absoluteMain) {
|
|
21
|
+
this.sources.push((0, url_1.fileURLToPath)(url.href));
|
|
20
22
|
}
|
|
21
23
|
});
|
|
22
24
|
}
|
|
@@ -39,3 +41,26 @@ class SassSources {
|
|
|
39
41
|
}
|
|
40
42
|
}
|
|
41
43
|
exports.SassSources = SassSources;
|
|
44
|
+
function getChecker() {
|
|
45
|
+
return sourcesChecker;
|
|
46
|
+
}
|
|
47
|
+
exports.getChecker = getChecker;
|
|
48
|
+
function clearSourcesChecker() {
|
|
49
|
+
sourcesChecker.splice(0, sourcesChecker.length);
|
|
50
|
+
}
|
|
51
|
+
exports.clearSourcesChecker = clearSourcesChecker;
|
|
52
|
+
function addResultToSourcesChecker(fileName, result) {
|
|
53
|
+
let resultExistsInChecker = false;
|
|
54
|
+
let ind = 0;
|
|
55
|
+
while (ind < sourcesChecker.length && resultExistsInChecker === false) {
|
|
56
|
+
if (sourcesChecker[ind].getAbsoluteMain() === path_1.default.resolve(fileName)) {
|
|
57
|
+
sourcesChecker[ind].setSources(result.loadedUrls);
|
|
58
|
+
resultExistsInChecker = true;
|
|
59
|
+
}
|
|
60
|
+
ind = ind + 1;
|
|
61
|
+
}
|
|
62
|
+
if (resultExistsInChecker === false) {
|
|
63
|
+
sourcesChecker.push(new SassSources(fileName, result));
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
exports.addResultToSourcesChecker = addResultToSourcesChecker;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sheetloaf",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.1-beta.2",
|
|
4
4
|
"description": "freshmade stylesheets for the whole family.",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -52,6 +52,7 @@
|
|
|
52
52
|
"chokidar": "^3.5.3",
|
|
53
53
|
"commander": "^9.4.0",
|
|
54
54
|
"fast-glob": "^3.2.11",
|
|
55
|
+
"path-equal": "^1.2.2",
|
|
55
56
|
"picocolors": "^1.0.0",
|
|
56
57
|
"picomatch": "^2.3.1",
|
|
57
58
|
"sass": "^1.54.4"
|