sheetloaf 1.3.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 +9 -16
- package/dist/sources.js +24 -1
- package/package.json +1 -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.0", '-v, --version', 'Print the version of Sheetloaf.');
|
|
50
|
+
sheetloaf.version("1.3.1-beta.0", '-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,15 @@ function renderPartially(source, fileName) {
|
|
|
115
115
|
}
|
|
116
116
|
else {
|
|
117
117
|
let partialExistsInSassSources = false;
|
|
118
|
-
for (let i = 0; i <
|
|
119
|
-
if (
|
|
118
|
+
for (let i = 0; i < sources.getChecker().length; i++) {
|
|
119
|
+
if (sources.getChecker()[i].containsPartial(fileName)) {
|
|
120
120
|
partialExistsInSassSources = true;
|
|
121
|
-
renderSass(
|
|
121
|
+
renderSass(sources.getChecker()[i].getMain());
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
124
|
if (partialExistsInSassSources === false) {
|
|
125
125
|
console.log(fileName);
|
|
126
|
-
|
|
126
|
+
sources.clearSourcesChecker();
|
|
127
127
|
renderAllFiles(source);
|
|
128
128
|
}
|
|
129
129
|
}
|
|
@@ -146,7 +146,7 @@ function watch(source) {
|
|
|
146
146
|
})
|
|
147
147
|
.on('add', (added) => {
|
|
148
148
|
console.log(`File added: ${added}`);
|
|
149
|
-
|
|
149
|
+
sources.clearSourcesChecker();
|
|
150
150
|
renderAllFiles(source);
|
|
151
151
|
});
|
|
152
152
|
}
|
|
@@ -160,13 +160,13 @@ function renderSass(fileName) {
|
|
|
160
160
|
const options = configs.generateSassOptionsAsync(sheetloaf.opts());
|
|
161
161
|
const result = yield sass_1.default.compileAsync(fileName, options);
|
|
162
162
|
renderPost(fileName, destination, result);
|
|
163
|
-
addResultToSourcesChecker(fileName, result);
|
|
163
|
+
sources.addResultToSourcesChecker(fileName, result);
|
|
164
164
|
}
|
|
165
165
|
else {
|
|
166
166
|
const options = configs.generateSassOptions(sheetloaf.opts());
|
|
167
167
|
const result = sass_1.default.compile(fileName, options);
|
|
168
168
|
renderPost(fileName, destination, result);
|
|
169
|
-
addResultToSourcesChecker(fileName, result);
|
|
169
|
+
sources.addResultToSourcesChecker(fileName, result);
|
|
170
170
|
}
|
|
171
171
|
}
|
|
172
172
|
catch (e) {
|
|
@@ -308,10 +308,3 @@ function emitSassError(err) {
|
|
|
308
308
|
`;
|
|
309
309
|
return css;
|
|
310
310
|
}
|
|
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,9 @@ 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
10
|
constructor(fileName, sassResult) {
|
|
10
11
|
this.sources = [];
|
|
@@ -39,3 +40,25 @@ class SassSources {
|
|
|
39
40
|
}
|
|
40
41
|
}
|
|
41
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;
|