sheetloaf 1.2.0-beta.0 → 1.2.0-beta.3
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/configs.js +51 -0
- package/dist/fileFinder.js +108 -0
- package/dist/index.js +286 -0
- package/package.json +2 -3
package/dist/configs.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.generateSassOptionsAsync = exports.generateSassOptions = exports.generatePostcssConfigFromUse = exports.generatePostcssConfigFromFile = void 0;
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const fs_1 = __importDefault(require("fs"));
|
|
9
|
+
function generatePostcssConfigFromFile(configPath = '') {
|
|
10
|
+
let obj = {
|
|
11
|
+
plugins: []
|
|
12
|
+
};
|
|
13
|
+
let configFileLoc = path_1.default.resolve(process.cwd(), configPath, 'postcss.config.js');
|
|
14
|
+
try {
|
|
15
|
+
fs_1.default.lstatSync(configFileLoc);
|
|
16
|
+
obj = require(configFileLoc);
|
|
17
|
+
}
|
|
18
|
+
catch (e) {
|
|
19
|
+
console.log(`No postcss.config.js file found at location ${configPath}`);
|
|
20
|
+
}
|
|
21
|
+
return obj;
|
|
22
|
+
}
|
|
23
|
+
exports.generatePostcssConfigFromFile = generatePostcssConfigFromFile;
|
|
24
|
+
function generatePostcssConfigFromUse(useArg) {
|
|
25
|
+
let obj = {
|
|
26
|
+
plugins: []
|
|
27
|
+
};
|
|
28
|
+
useArg.split(',').forEach(function (plugin) {
|
|
29
|
+
obj.plugins.push(require(plugin));
|
|
30
|
+
});
|
|
31
|
+
return obj;
|
|
32
|
+
}
|
|
33
|
+
exports.generatePostcssConfigFromUse = generatePostcssConfigFromUse;
|
|
34
|
+
function generateSassOptions(opts) {
|
|
35
|
+
return {
|
|
36
|
+
style: opts.style,
|
|
37
|
+
loadPaths: opts.loadPath ? opts.loadPath.split(',') : [],
|
|
38
|
+
sourceMap: opts.sourceMap === false ? false : true,
|
|
39
|
+
sourceMapIncludeSources: opts.sourceMap === false ? false : true
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
exports.generateSassOptions = generateSassOptions;
|
|
43
|
+
function generateSassOptionsAsync(opts) {
|
|
44
|
+
return {
|
|
45
|
+
style: opts.style,
|
|
46
|
+
loadPaths: opts.loadPath ? opts.loadPath.split(',') : [],
|
|
47
|
+
sourceMap: opts.sourceMap === false ? false : true,
|
|
48
|
+
sourceMapIncludeSources: opts.sourceMap === false ? false : true
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
exports.generateSassOptionsAsync = generateSassOptionsAsync;
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.buildDestinationPath = exports.getAllFilesPathsFromSources = void 0;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const picomatch_1 = __importDefault(require("picomatch"));
|
|
10
|
+
const fast_glob_1 = __importDefault(require("fast-glob"));
|
|
11
|
+
function getAllFilesPathsFromSources(input, callback) {
|
|
12
|
+
let sourcesCompleted = 0;
|
|
13
|
+
let filePaths = [];
|
|
14
|
+
for (let i = 0; i < input.length; i++) {
|
|
15
|
+
let isGlob, isDir, isFile = false;
|
|
16
|
+
isGlob = picomatch_1.default.scan(input[i]).isGlob;
|
|
17
|
+
if (isGlob === true) {
|
|
18
|
+
getGlobPaths(input[i], (files) => {
|
|
19
|
+
filePaths.push(...files);
|
|
20
|
+
sourcesCompleted++;
|
|
21
|
+
if (sourcesCompleted === input.length) {
|
|
22
|
+
callback([...new Set(filePaths)].sort());
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
try {
|
|
28
|
+
isDir = fs_1.default.lstatSync(path_1.default.normalize(input[i])).isDirectory();
|
|
29
|
+
isFile = fs_1.default.lstatSync(path_1.default.normalize(input[i])).isFile();
|
|
30
|
+
if (isFile) {
|
|
31
|
+
getGlobPaths(input[i], (files) => {
|
|
32
|
+
filePaths.push(...files);
|
|
33
|
+
sourcesCompleted++;
|
|
34
|
+
if (sourcesCompleted === input.length) {
|
|
35
|
+
callback([...new Set(filePaths)].sort());
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
else if (isDir) {
|
|
40
|
+
getAllFilePathsInDir(input[i], (files) => {
|
|
41
|
+
filePaths.push(...files);
|
|
42
|
+
sourcesCompleted++;
|
|
43
|
+
if (sourcesCompleted === input.length) {
|
|
44
|
+
callback([...new Set(filePaths)].sort());
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
catch (err) {
|
|
50
|
+
throw err;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
exports.getAllFilesPathsFromSources = getAllFilesPathsFromSources;
|
|
56
|
+
function getGlobPaths(glob, callback) {
|
|
57
|
+
let expanded = fast_glob_1.default
|
|
58
|
+
.sync(glob, {
|
|
59
|
+
dot: true
|
|
60
|
+
})
|
|
61
|
+
.map((entry) => path_1.default.normalize(entry));
|
|
62
|
+
callback(expanded);
|
|
63
|
+
}
|
|
64
|
+
function getAllFilePathsInDir(dir, callback) {
|
|
65
|
+
let files = [];
|
|
66
|
+
fs_1.default.readdir(dir, (err, nodes) => {
|
|
67
|
+
if (err) {
|
|
68
|
+
throw err;
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
nodes.forEach((file) => {
|
|
72
|
+
let fullname = path_1.default.join(dir, file);
|
|
73
|
+
if (!fs_1.default.lstatSync(fullname).isDirectory()) {
|
|
74
|
+
files.push(fullname);
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
callback(files);
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
function buildDestinationPath(fileName, outFile = '', dir = '', base = '', extension = '.css', usingStdin) {
|
|
82
|
+
let destination = '';
|
|
83
|
+
let mirror = '';
|
|
84
|
+
if (usingStdin === true) {
|
|
85
|
+
if (outFile.length > 0) {
|
|
86
|
+
destination = outFile;
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
destination = '';
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
if (dir.length > 0) {
|
|
94
|
+
if (base.length > 0) {
|
|
95
|
+
mirror = path_1.default.dirname(fileName.replace(path_1.default.join(base, '/'), ''));
|
|
96
|
+
}
|
|
97
|
+
destination = path_1.default.join(dir, mirror, path_1.default.basename(fileName, path_1.default.extname(fileName)) + extension);
|
|
98
|
+
}
|
|
99
|
+
else if (outFile.length > 0) {
|
|
100
|
+
destination = outFile;
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
destination = '';
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return destination;
|
|
107
|
+
}
|
|
108
|
+
exports.buildDestinationPath = buildDestinationPath;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
20
|
+
if (mod && mod.__esModule) return mod;
|
|
21
|
+
var result = {};
|
|
22
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
23
|
+
__setModuleDefault(result, mod);
|
|
24
|
+
return result;
|
|
25
|
+
};
|
|
26
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
27
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
28
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
29
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
30
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
31
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
32
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
const commander_1 = require("commander");
|
|
40
|
+
const chokidar_1 = __importDefault(require("chokidar"));
|
|
41
|
+
const picocolors_1 = __importDefault(require("picocolors"));
|
|
42
|
+
const fs_1 = __importDefault(require("fs"));
|
|
43
|
+
const path_1 = __importDefault(require("path"));
|
|
44
|
+
const sass_1 = __importDefault(require("sass"));
|
|
45
|
+
const postcss_1 = __importDefault(require("postcss"));
|
|
46
|
+
const configs = __importStar(require("./configs"));
|
|
47
|
+
const fileFinder = __importStar(require("./fileFinder"));
|
|
48
|
+
const sheetloaf = new commander_1.Command();
|
|
49
|
+
sheetloaf.version("1.2.0", '-v, --version', 'Print the version of Sheetloaf.');
|
|
50
|
+
let usingStdin = false;
|
|
51
|
+
let postcssConfig = {
|
|
52
|
+
plugins: []
|
|
53
|
+
};
|
|
54
|
+
sheetloaf
|
|
55
|
+
.arguments('[sources...]')
|
|
56
|
+
.description('📃🍞 Compile Sass to CSS and transform the output using PostCSS, all in one command.')
|
|
57
|
+
.action((source) => {
|
|
58
|
+
if (sheetloaf.opts().use) {
|
|
59
|
+
postcssConfig = configs.generatePostcssConfigFromUse(sheetloaf.opts().use);
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
postcssConfig = configs.generatePostcssConfigFromFile(sheetloaf.opts().config);
|
|
63
|
+
}
|
|
64
|
+
if (source.length > 0) {
|
|
65
|
+
renderAllFiles(source);
|
|
66
|
+
watch(source);
|
|
67
|
+
}
|
|
68
|
+
else if (!process.stdin.isTTY) {
|
|
69
|
+
let stdin = '';
|
|
70
|
+
process.stdin.on('readable', () => {
|
|
71
|
+
var chunk = process.stdin.read();
|
|
72
|
+
if (chunk !== null) {
|
|
73
|
+
stdin += chunk;
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
process.stdin.on('end', () => {
|
|
77
|
+
usingStdin = true;
|
|
78
|
+
renderSassFromStdin(stdin);
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
sheetloaf
|
|
83
|
+
.option('-o, --output <LOCATION>', 'Output file.')
|
|
84
|
+
.option('--dir <LOCATION>', 'Output directory.')
|
|
85
|
+
.option('--base <DIR>', 'Mirror the directory structure relative to this path in the output directory, for use with --dir.', '')
|
|
86
|
+
.option('--ext <EXTENSION>', 'Override the output file extension; for use with --dir', '.css')
|
|
87
|
+
.option('-s, --style <NAME>', 'Output style. ["expanded", "compressed"]', 'expanded')
|
|
88
|
+
.option('--source-map', 'Generate a source map (this is the default option).')
|
|
89
|
+
.option('--no-source-map', 'Do not generate a source map.')
|
|
90
|
+
.option('--embed-source-map', 'Embed the contents of the source map file in the generated CSS, rather than creating a separate file and linking to it from the CSS.')
|
|
91
|
+
.option('--embed-sources', 'Embed the entire contents of the Sass files that contributed to the generated CSS in the source map.')
|
|
92
|
+
.option('--source-map-urls <TYPE>', 'Controls how the source maps that Sass generates link back to the Sass files that contributed to the generated CSS. ["relative", "absolute"]', 'relative')
|
|
93
|
+
.option('--error-css', 'Emit a CSS file when an error occurs during compilation (this is the default option).')
|
|
94
|
+
.option('--no-error-css', 'Do not emit a CSS file when an error occurs during compilation.')
|
|
95
|
+
.option('-I, --load-path <PATHS>', 'Adds an additional load path for Sass to look for stylesheets.')
|
|
96
|
+
.option('-w, --watch', 'Watch stylesheets and recompile when they change.')
|
|
97
|
+
.option('--config <LOCATION>', 'Set a custom directory to look for a postcss config file.')
|
|
98
|
+
.option('--poll [DURATION]', 'Use polling for file watching. Can optionally pass polling interval; default 100 ms')
|
|
99
|
+
.option('-u, --use <PLUGINS>', 'List of postcss plugins to use. Will cause sheetloaf to ignore any config files.')
|
|
100
|
+
.option('--async', `Use sass' asynchronous API. This may be slower.`);
|
|
101
|
+
sheetloaf.parse(process.argv);
|
|
102
|
+
function renderAllFiles(source) {
|
|
103
|
+
fileFinder.getAllFilesPathsFromSources(source[0].split(','), function (entries) {
|
|
104
|
+
entries.forEach(function (fileName) {
|
|
105
|
+
if (path_1.default.basename(fileName).charAt(0) !== '_') {
|
|
106
|
+
renderSass(fileName);
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
function watch(source) {
|
|
112
|
+
if (sheetloaf.opts().watch === true) {
|
|
113
|
+
chokidar_1.default
|
|
114
|
+
.watch(source[0].split(','), {
|
|
115
|
+
usePolling: sheetloaf.opts().poll !== undefined,
|
|
116
|
+
interval: typeof sheetloaf.opts().poll === 'number' ? sheetloaf.opts().poll : 100,
|
|
117
|
+
ignoreInitial: true,
|
|
118
|
+
awaitWriteFinish: {
|
|
119
|
+
stabilityThreshold: 1500,
|
|
120
|
+
pollInterval: 100
|
|
121
|
+
}
|
|
122
|
+
})
|
|
123
|
+
.on('change', (changed) => {
|
|
124
|
+
console.log(`File changed: ${changed}`);
|
|
125
|
+
renderAllFiles(source);
|
|
126
|
+
})
|
|
127
|
+
.on('add', (added) => {
|
|
128
|
+
console.log(`File added: ${added}`);
|
|
129
|
+
renderAllFiles(source);
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
function renderSass(fileName) {
|
|
134
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
135
|
+
if (usingStdin === false) {
|
|
136
|
+
console.log(`Rendering ${fileName}...`);
|
|
137
|
+
}
|
|
138
|
+
const destination = fileFinder.buildDestinationPath(fileName, sheetloaf.opts().output, sheetloaf.opts().dir, sheetloaf.opts().base, sheetloaf.opts().ext, usingStdin);
|
|
139
|
+
try {
|
|
140
|
+
if (sheetloaf.opts().async === true) {
|
|
141
|
+
const options = configs.generateSassOptionsAsync(sheetloaf.opts());
|
|
142
|
+
const result = yield sass_1.default.compileAsync(fileName, options);
|
|
143
|
+
renderPost(fileName, destination, result);
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
const options = configs.generateSassOptions(sheetloaf.opts());
|
|
147
|
+
const result = sass_1.default.compile(fileName, options);
|
|
148
|
+
renderPost(fileName, destination, result);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
catch (e) {
|
|
152
|
+
sassErrorCatcher(e, destination);
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
function renderSassFromStdin(text) {
|
|
157
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
158
|
+
const destination = fileFinder.buildDestinationPath('', sheetloaf.opts().output, sheetloaf.opts().dir, sheetloaf.opts().base, sheetloaf.opts().ext, usingStdin);
|
|
159
|
+
try {
|
|
160
|
+
if (sheetloaf.opts().async === true) {
|
|
161
|
+
const options = configs.generateSassOptionsAsync(sheetloaf.opts());
|
|
162
|
+
const result = yield sass_1.default.compileStringAsync(text, options);
|
|
163
|
+
renderPost('', destination, result);
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
const options = configs.generateSassOptions(sheetloaf.opts());
|
|
167
|
+
const result = sass_1.default.compileString(text, options);
|
|
168
|
+
renderPost('', destination, result);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
catch (e) {
|
|
172
|
+
sassErrorCatcher(e, destination);
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
function renderPost(fileName, destination, sassResult) {
|
|
177
|
+
let postcssMapOptions = {
|
|
178
|
+
annotation: true,
|
|
179
|
+
prev: sassResult.sourceMap,
|
|
180
|
+
inline: sheetloaf.opts().embedSourceMap === true ? true : false,
|
|
181
|
+
absolute: sheetloaf.opts().sourceMapUrls === 'absolute' ? true : false,
|
|
182
|
+
sourcesContent: sheetloaf.opts().embedSources === true ? true : false,
|
|
183
|
+
};
|
|
184
|
+
if (usingStdin === true || sheetloaf.opts().sourceMap === false) {
|
|
185
|
+
postcssMapOptions = false;
|
|
186
|
+
}
|
|
187
|
+
(0, postcss_1.default)(postcssConfig.plugins)
|
|
188
|
+
.process(sassResult.css.toString(), {
|
|
189
|
+
from: fileName,
|
|
190
|
+
to: destination,
|
|
191
|
+
map: postcssMapOptions
|
|
192
|
+
})
|
|
193
|
+
.then((postedResult) => {
|
|
194
|
+
postedResult.warnings().forEach((warn) => {
|
|
195
|
+
process.stderr.write(warn.toString());
|
|
196
|
+
});
|
|
197
|
+
if (destination !== '') {
|
|
198
|
+
try {
|
|
199
|
+
fs_1.default.mkdirSync(path_1.default.dirname(destination), {
|
|
200
|
+
recursive: true
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
catch (err) {
|
|
204
|
+
if (err.code !== 'EEXIST' || err.code !== 'EISDIR')
|
|
205
|
+
throw err;
|
|
206
|
+
}
|
|
207
|
+
fs_1.default.writeFile(destination, postedResult.css, (err) => {
|
|
208
|
+
if (err)
|
|
209
|
+
throw err;
|
|
210
|
+
console.log(picocolors_1.default.green(`Successfully written to ${destination}`));
|
|
211
|
+
});
|
|
212
|
+
if (postedResult.map) {
|
|
213
|
+
fs_1.default.writeFile(destination + '.map', postedResult.map.toString(), (err) => {
|
|
214
|
+
if (err)
|
|
215
|
+
throw err;
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
else {
|
|
220
|
+
process.stdout.write(postedResult.css);
|
|
221
|
+
}
|
|
222
|
+
})
|
|
223
|
+
.catch((err) => {
|
|
224
|
+
if (destination !== '') {
|
|
225
|
+
console.log(picocolors_1.default.red(err));
|
|
226
|
+
}
|
|
227
|
+
else {
|
|
228
|
+
process.stderr.write(err);
|
|
229
|
+
}
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
function sassErrorCatcher(e, destination) {
|
|
233
|
+
if (destination !== '') {
|
|
234
|
+
console.log(e.message);
|
|
235
|
+
try {
|
|
236
|
+
fs_1.default.mkdirSync(path_1.default.dirname(destination), {
|
|
237
|
+
recursive: true
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
catch (mkDirErr) {
|
|
241
|
+
if (mkDirErr.code !== 'EEXIST' || mkDirErr.code !== 'EISDIR')
|
|
242
|
+
throw mkDirErr;
|
|
243
|
+
}
|
|
244
|
+
if (sheetloaf.opts().errorCss !== false) {
|
|
245
|
+
fs_1.default.writeFile(destination, emitSassError(e), (writeFileErr) => {
|
|
246
|
+
if (writeFileErr)
|
|
247
|
+
throw writeFileErr;
|
|
248
|
+
console.log(picocolors_1.default.yellow(`Emitted error to ${destination}`));
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
else {
|
|
253
|
+
process.stderr.write(e.message);
|
|
254
|
+
}
|
|
255
|
+
if (!sheetloaf.opts().watch && (process.exitCode == null || process.exitCode === 0)) {
|
|
256
|
+
process.exitCode = 1;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
function emitSassError(err) {
|
|
260
|
+
const span = err.span.toString().replace(/'.*'/i, '');
|
|
261
|
+
const message = err.sassMessage.toString().replace(/'.*'/i, '');
|
|
262
|
+
let css = `
|
|
263
|
+
body:before {
|
|
264
|
+
content: 'Error from ${span}';
|
|
265
|
+
display: table;
|
|
266
|
+
background-color:#cc0000;
|
|
267
|
+
color:white;
|
|
268
|
+
border-radius:5px;
|
|
269
|
+
margin-bottom:5px;
|
|
270
|
+
padding:5px;
|
|
271
|
+
font-family:sans-serif
|
|
272
|
+
}
|
|
273
|
+
body:after {
|
|
274
|
+
content: "${message}";
|
|
275
|
+
display: table;
|
|
276
|
+
background-color:#0e70b0;
|
|
277
|
+
color:white;
|
|
278
|
+
border-radius:5px;
|
|
279
|
+
padding:5px;
|
|
280
|
+
margin-bottom: 5px;
|
|
281
|
+
font-family:sans-serif
|
|
282
|
+
}
|
|
283
|
+
body * { display: none; }
|
|
284
|
+
`;
|
|
285
|
+
return css;
|
|
286
|
+
}
|
package/package.json
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sheetloaf",
|
|
3
|
-
"version": "1.2.0-beta.
|
|
3
|
+
"version": "1.2.0-beta.3",
|
|
4
4
|
"description": "freshmade stylesheets for the whole family.",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"bin": {
|
|
7
7
|
"sheetloaf": "./dist/index.js"
|
|
8
8
|
},
|
|
9
|
-
"type": "module",
|
|
10
9
|
"scripts": {
|
|
11
10
|
"build:development": "tsc --watch",
|
|
12
11
|
"build:production": "tsc",
|
|
@@ -57,4 +56,4 @@
|
|
|
57
56
|
"picomatch": "^2.3.1",
|
|
58
57
|
"sass": "^1.54.3"
|
|
59
58
|
}
|
|
60
|
-
}
|
|
59
|
+
}
|