sheetloaf 1.3.0-beta.0 → 1.3.1-beta.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/dist/index.js +16 -21
- package/dist/sources.js +32 -5
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -47,12 +47,11 @@ const configs = __importStar(require("./configs"));
|
|
|
47
47
|
const fileFinder = __importStar(require("./fileFinder"));
|
|
48
48
|
const sources = __importStar(require("./sources"));
|
|
49
49
|
const sheetloaf = new commander_1.Command();
|
|
50
|
-
sheetloaf.version("1.3.0", '-v, --version', 'Print the version of Sheetloaf.');
|
|
50
|
+
sheetloaf.version("1.3.1-beta.0", '-v, --version', 'Print the version of Sheetloaf.');
|
|
51
51
|
let usingStdin = false;
|
|
52
52
|
let postcssConfig = {
|
|
53
53
|
plugins: []
|
|
54
54
|
};
|
|
55
|
-
let sourcesChecker = [];
|
|
56
55
|
sheetloaf
|
|
57
56
|
.arguments('[sources...]')
|
|
58
57
|
.description('📃🍞 Compile Sass to CSS and transform the output using PostCSS, all in one command.')
|
|
@@ -110,16 +109,23 @@ function renderAllFiles(source) {
|
|
|
110
109
|
});
|
|
111
110
|
});
|
|
112
111
|
}
|
|
113
|
-
function renderPartially(fileName) {
|
|
112
|
+
function renderPartially(source, fileName) {
|
|
114
113
|
if (path_1.default.basename(fileName).charAt(0) !== '_') {
|
|
115
114
|
renderSass(fileName);
|
|
116
115
|
}
|
|
117
116
|
else {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
117
|
+
let partialExistsInSassSources = false;
|
|
118
|
+
for (let i = 0; i < sources.getChecker().length; i++) {
|
|
119
|
+
if (sources.getChecker()[i].containsPartial(fileName)) {
|
|
120
|
+
partialExistsInSassSources = true;
|
|
121
|
+
renderSass(sources.getChecker()[i].getMain());
|
|
121
122
|
}
|
|
122
123
|
}
|
|
124
|
+
if (partialExistsInSassSources === false) {
|
|
125
|
+
console.log(fileName);
|
|
126
|
+
sources.clearSourcesChecker();
|
|
127
|
+
renderAllFiles(source);
|
|
128
|
+
}
|
|
123
129
|
}
|
|
124
130
|
}
|
|
125
131
|
function watch(source) {
|
|
@@ -136,11 +142,11 @@ function watch(source) {
|
|
|
136
142
|
})
|
|
137
143
|
.on('change', (changed) => {
|
|
138
144
|
console.log(`File changed: ${changed}`);
|
|
139
|
-
renderPartially(changed);
|
|
145
|
+
renderPartially(source, changed);
|
|
140
146
|
})
|
|
141
147
|
.on('add', (added) => {
|
|
142
148
|
console.log(`File added: ${added}`);
|
|
143
|
-
|
|
149
|
+
sources.clearSourcesChecker();
|
|
144
150
|
renderAllFiles(source);
|
|
145
151
|
});
|
|
146
152
|
}
|
|
@@ -154,13 +160,13 @@ function renderSass(fileName) {
|
|
|
154
160
|
const options = configs.generateSassOptionsAsync(sheetloaf.opts());
|
|
155
161
|
const result = yield sass_1.default.compileAsync(fileName, options);
|
|
156
162
|
renderPost(fileName, destination, result);
|
|
157
|
-
addResultToSourcesChecker(fileName, result);
|
|
163
|
+
sources.addResultToSourcesChecker(fileName, result);
|
|
158
164
|
}
|
|
159
165
|
else {
|
|
160
166
|
const options = configs.generateSassOptions(sheetloaf.opts());
|
|
161
167
|
const result = sass_1.default.compile(fileName, options);
|
|
162
168
|
renderPost(fileName, destination, result);
|
|
163
|
-
addResultToSourcesChecker(fileName, result);
|
|
169
|
+
sources.addResultToSourcesChecker(fileName, result);
|
|
164
170
|
}
|
|
165
171
|
}
|
|
166
172
|
catch (e) {
|
|
@@ -302,14 +308,3 @@ function emitSassError(err) {
|
|
|
302
308
|
`;
|
|
303
309
|
return css;
|
|
304
310
|
}
|
|
305
|
-
function addResultToSourcesChecker(fileName, result) {
|
|
306
|
-
let alreadyExists = false;
|
|
307
|
-
for (let i = 0; i < sourcesChecker.length; i++) {
|
|
308
|
-
if (sourcesChecker[i].getAbsoluteMain() === path_1.default.resolve(fileName)) {
|
|
309
|
-
alreadyExists = true;
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
if (alreadyExists === false) {
|
|
313
|
-
sourcesChecker.push(new sources.SassSources(fileName, result));
|
|
314
|
-
}
|
|
315
|
-
}
|
package/dist/sources.js
CHANGED
|
@@ -3,14 +3,19 @@ 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
|
+
let sourcesChecker = [];
|
|
8
9
|
class SassSources {
|
|
9
|
-
constructor(
|
|
10
|
+
constructor(fileName, sassResult) {
|
|
10
11
|
this.sources = [];
|
|
11
|
-
this.main =
|
|
12
|
-
this.absoluteMain = path_1.default.resolve(
|
|
13
|
-
sassResult.loadedUrls
|
|
12
|
+
this.main = fileName;
|
|
13
|
+
this.absoluteMain = path_1.default.resolve(fileName);
|
|
14
|
+
this.setSources(sassResult.loadedUrls);
|
|
15
|
+
}
|
|
16
|
+
setSources(urls) {
|
|
17
|
+
this.sources.splice(0, this.sources.length);
|
|
18
|
+
urls.forEach(url => {
|
|
14
19
|
if (url.pathname !== this.absoluteMain) {
|
|
15
20
|
this.sources.push(url.pathname);
|
|
16
21
|
}
|
|
@@ -35,3 +40,25 @@ class SassSources {
|
|
|
35
40
|
}
|
|
36
41
|
}
|
|
37
42
|
exports.SassSources = SassSources;
|
|
43
|
+
function getChecker() {
|
|
44
|
+
return sourcesChecker;
|
|
45
|
+
}
|
|
46
|
+
exports.getChecker = getChecker;
|
|
47
|
+
function clearSourcesChecker() {
|
|
48
|
+
sourcesChecker.splice(0, sourcesChecker.length);
|
|
49
|
+
}
|
|
50
|
+
exports.clearSourcesChecker = clearSourcesChecker;
|
|
51
|
+
function addResultToSourcesChecker(fileName, result) {
|
|
52
|
+
let resultExistsInChecker = false;
|
|
53
|
+
sourcesChecker.every((source) => {
|
|
54
|
+
if (source.getAbsoluteMain() === path_1.default.resolve(fileName)) {
|
|
55
|
+
source.setSources(result.loadedUrls);
|
|
56
|
+
resultExistsInChecker = true;
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
if (resultExistsInChecker === false) {
|
|
61
|
+
sourcesChecker.push(new SassSources(fileName, result));
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
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.0",
|
|
4
4
|
"description": "freshmade stylesheets for the whole family.",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -54,6 +54,6 @@
|
|
|
54
54
|
"fast-glob": "^3.2.11",
|
|
55
55
|
"picocolors": "^1.0.0",
|
|
56
56
|
"picomatch": "^2.3.1",
|
|
57
|
-
"sass": "^1.54.
|
|
57
|
+
"sass": "^1.54.4"
|
|
58
58
|
}
|
|
59
59
|
}
|