aliascss 1.4.3 → 1.4.5

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.
@@ -1,75 +1,102 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
1
10
  import extractClassNamesFromFile from "./extractClassNamesFromFile.js";
2
11
  import { compiler as statementMaker } from "../returnStatement.js";
3
- import config from '../config.js';
12
+ import config from "../config.js";
4
13
  import fs from "fs";
5
14
  import fg from "fast-glob";
6
- import path from 'path';
7
- import postcss from 'postcss';
8
- import postcssDiscardDuplicates from 'postcss-discard-duplicates';
9
- import cssnano from 'cssnano';
10
- import chokidar from 'chokidar';
11
- import sortMediaQueries from 'postcss-sort-media-queries';
15
+ import path from "path";
16
+ import postcss from "postcss";
17
+ import postcssDiscardDuplicates from "postcss-discard-duplicates";
18
+ import cssnano from "cssnano";
19
+ import chokidar from "chokidar";
20
+ import sortMediaQueries from "postcss-sort-media-queries";
21
+ import { splitByCommaOutsideParens } from "../utils/helper.js";
12
22
  const init = {
13
- classList: [], // hold className for MasterCSS to avoid repeating
23
+ classList: [],
14
24
  groups: [],
15
- input: '', // input glob pattern
16
- output: '', // location off output
17
- '--file': false, // if set true compileFileByFile to [filename].css
25
+ input: "",
26
+ output: "",
27
+ "--file": false,
18
28
  statementMaker,
19
29
  config,
20
- '--module': false,
21
- rawCSS: '',
30
+ "--module": false,
31
+ rawCSS: "",
22
32
  layers: [],
23
- customGroupStatement: '',
33
+ initializedLayer: false,
34
+ customGroupStatement: "",
24
35
  minify: false,
25
- globPattern: '', // Use this to check valid new created file to add to watch during watch.on
36
+ globPattern: "",
26
37
  };
27
38
  export default function main(config) {
28
- // initialize
29
- initialize(config);
30
- if (init.config.prefix)
31
- init.statementMaker.prefix = init.config.prefix;
32
- if (init.input && (init.output || init['--file'])) {
33
- const input = fg.sync(init.input, { dot: true });
34
- // console.log(input);
35
- input.forEach((file) => {
36
- createCSSFileByFile(file);
37
- });
38
- postify(init.output, [postcssDiscardDuplicates], init.minify);
39
- }
40
- else {
41
- console.error("Please Provide input, output or set '--file' to true");
42
- }
39
+ return __awaiter(this, void 0, void 0, function* () {
40
+ initialize(config);
41
+ if (init.config.prefix)
42
+ init.statementMaker.prefix = init.config.prefix;
43
+ if (init.input && (init.output || init["--file"])) {
44
+ const input = fg.sync(init.input, { dot: true });
45
+ input.forEach((file) => {
46
+ createCSSFileByFile(file, true);
47
+ });
48
+ if (init.output) {
49
+ yield globalCSSCompiler();
50
+ }
51
+ }
52
+ else {
53
+ console.error("Please Provide input, output or set '--file' to true");
54
+ }
55
+ });
43
56
  }
44
57
  export function globalCSSCompiler() {
45
- const classList = [];
46
- if (init.globPattern && init.output) {
47
- fs.truncateSync(init.output);
48
- const input = fg.sync(init.globPattern, { dot: true });
49
- // console.log(input);
50
- input.forEach((file) => {
51
- const [gbContent,] = compileFile(file, config, statementMaker, classList);
52
- try {
53
- fs.writeFileSync(init.output, `@layer ${init.layers.join(', ')};
54
- \n/* Start :-----------ACSS ${path.relative('.', file)}------------------------*/\n${gbContent}
55
- \n/* End :-----------ACSS ${path.relative('.', file)}----------------------------*/\n
56
- `, { flag: 'a+' });
57
- console.log('AliasCSS compiled', path.relative('.', file), 'to main css file :' + init.output);
58
+ return __awaiter(this, void 0, void 0, function* () {
59
+ const classList = [];
60
+ if (init.globPattern && init.output) {
61
+ fs.truncateSync(init.output);
62
+ let basePreamble = "";
63
+ // 1. Layer declaration
64
+ if (Array.isArray(init.layers) && init.layers.length > 0) {
65
+ basePreamble += `@layer ${init.layers.join(", ")};\n\n`;
66
+ init.initializedLayer = true;
58
67
  }
59
- catch (error) {
60
- console.log('\x1b[31m', "Couldn't able to append/create to main css file :" + init.output);
61
- console.log(error);
68
+ // 2. Custom CSS statements & group statements
69
+ if (init.rawCSS) {
70
+ basePreamble += `/* Start :-----------ACSS:From aliasCSSConfig.statement------------------------*/\n${init.rawCSS}\n/* End :-----------ACSS aliasCSSConfig.statement----------------------------*/\n\n`;
62
71
  }
63
- });
64
- postify(init.output, [postcssDiscardDuplicates], init.minify);
65
- }
66
- else {
67
- console.error("Please Provide input, output or set '--file' to true");
68
- }
72
+ if (init.customGroupStatement) {
73
+ basePreamble += `/* Start :-----------ACSS:From aliasCSSConfig.group------------------------*/\n${init.customGroupStatement}\n/* End :-----------ACSS aliasCSSConfig.group----------------------------*/\n\n`;
74
+ }
75
+ if (basePreamble) {
76
+ fs.writeFileSync(init.output, basePreamble, { flag: "a+" });
77
+ }
78
+ // 3. Process matched files
79
+ const input = fg.sync(init.globPattern, { dot: true });
80
+ input.forEach((file) => {
81
+ const [gbContent] = compileFile(file, config, statementMaker, classList);
82
+ try {
83
+ fs.writeFileSync(init.output, `/* Start :-----------ACSS ${path.relative(".", file)}------------------------*/\n${gbContent}\n/* End :-----------ACSS ${path.relative(".", file)}----------------------------*/\n\n`, { flag: "a+" });
84
+ console.log("AliasCSS compiled", path.relative(".", file), "to main css file :" + init.output);
85
+ }
86
+ catch (error) {
87
+ console.log('\x1b[31m', "Couldn't able to append/create to main css file :" + init.output);
88
+ console.log(error);
89
+ }
90
+ });
91
+ yield postify(init.output, [postcssDiscardDuplicates], init.minify);
92
+ }
93
+ else {
94
+ console.error("Please Provide input, output or set '--file' to true");
95
+ }
96
+ });
69
97
  }
70
98
  export function compileFile(file, config, statementMaker, globalClassList) {
71
- let [globalStatement, compiledStatement, moduleStatement] = ['', '', ''];
72
- // inject config.group and config.statement
99
+ let [globalStatement, compiledStatement, moduleStatement] = ["", "", ""];
73
100
  if (statementMaker.rawCSS) {
74
101
  compiledStatement += `/* From:aliacss.config.statement */\n${statementMaker.rawCSS}\n/* -----End:aliacss.config.statement----- */\n\n`;
75
102
  moduleStatement += `/* From:aliacss.config.statement */\n${statementMaker.rawCSS}\n/* ------End:aliacss.config.statement----- */\n\n`;
@@ -79,290 +106,200 @@ export function compileFile(file, config, statementMaker, globalClassList) {
79
106
  moduleStatement += `/* From:aliacss.config.group */\n${statementMaker.customGroupStatement}\n/* -----End:aliacss.config.group----- */\n\n`;
80
107
  }
81
108
  const [classList, groups, keyframe, rawCSSStatement] = extractClassNamesFromFile(file, config);
82
- // 1. raw-css
83
109
  if (rawCSSStatement) {
84
- globalStatement += rawCSSStatement + '\n';
85
- compiledStatement += rawCSSStatement + '\n';
110
+ globalStatement += rawCSSStatement + "\n";
111
+ compiledStatement += rawCSSStatement + "\n";
86
112
  }
87
- // 2. group
88
113
  for (const key in groups) {
89
- if (groups.hasOwnProperty(key)) {
90
- // --------------ModuleStatement
114
+ if (Object.prototype.hasOwnProperty.call(groups, key)) {
91
115
  if (/^module=/.test(key)) {
92
- const mdStatement = statementMaker.group(groups[key], key.replace(/module=/, ''));
93
- moduleStatement += mdStatement + '\n';
116
+ moduleStatement += statementMaker.group(groups[key], key.replace(/module=/, "")) + "\n";
94
117
  }
95
- // -------------EndOfModule
96
118
  else {
97
119
  const gpStatement = statementMaker.group(groups[key], key);
98
- globalStatement += gpStatement + '\n';
99
- compiledStatement += gpStatement + '\n';
120
+ globalStatement += gpStatement + "\n";
121
+ compiledStatement += gpStatement + "\n";
100
122
  }
101
123
  }
102
124
  }
103
- // 2. ClassList
104
125
  classList.forEach((e) => {
105
126
  const statement = statementMaker.make(e);
106
127
  if (statement) {
107
- console.log('\x1b[32m', statement);
108
128
  if (globalClassList.indexOf(e) === -1) {
109
- globalStatement += statement + '\n';
129
+ globalStatement += statement + "\n";
110
130
  globalClassList.push(e);
111
- // console.log(e);
112
131
  }
113
- compiledStatement += statement + '\n';
132
+ compiledStatement += statement + "\n";
114
133
  }
115
134
  });
116
- // 3. Keyframe
117
135
  for (const key in keyframe) {
118
- if (keyframe.hasOwnProperty(key)) {
136
+ if (Object.prototype.hasOwnProperty.call(keyframe, key)) {
119
137
  const kfStatement = keyframesStatement(key, keyframe[key], statementMaker);
120
- globalStatement += kfStatement + '\n';
121
- compiledStatement += kfStatement + '\n';
138
+ globalStatement += kfStatement + "\n";
139
+ compiledStatement += kfStatement + "\n";
122
140
  }
123
141
  }
124
142
  return [globalStatement, compiledStatement, moduleStatement];
125
143
  }
126
144
  export function groupStatement(name, classNames, statementMaker) {
127
- return statementMaker.group(classNames, name) + '\n';
145
+ return statementMaker.group(classNames, name) + "\n";
128
146
  }
129
147
  export function keyframesStatement(name, timeLine, statementMaker) {
130
- let kfStatement = '@keyframes ' + name + "{\n";
148
+ let kfStatement = "@keyframes " + name + "{\n";
131
149
  const returnPnV = (e) => e.map((i) => statementMaker.make(i, null, true)).join(";");
132
150
  const split = timeLine.split(/\s+/);
133
151
  split.forEach((each) => {
134
152
  try {
135
- const [at, pNv] = each.replace(/\]\[/, ']-[').replace("-", "=").split("=");
136
- kfStatement += ` ${at.replace('@', '').replace(/:/g, ',').replace(/,/g, "%,").replace(/[\[|\]]/g, '')}% {${returnPnV(pNv.replace(/^\[|\]$/g, '').split(','))}}`;
153
+ const [at, pNv] = each.replace(/\]\[/, "]-[").replace("-", "=").split("=");
154
+ kfStatement += ` ${at.replace("@", "").replace(/:/g, ",").replace(/,/g, "%,").replace(/[\[|\]]/g, "")}% {${returnPnV(splitByCommaOutsideParens(pNv.replace(/^\[|\]$/g, "")))}}`;
137
155
  }
138
156
  catch (error) {
139
- console.error('Not a valid entry for AliasCSS keyframes processor : ' + each, error);
157
+ console.error("Not a valid entry for AliasCSS keyframes processor : " + each, error);
140
158
  }
141
159
  });
142
160
  return kfStatement + "\n}\n";
143
161
  }
144
- export function createCSSFileByFile(file, bool = false) {
145
- const [gbContent, content, module] = compileFile(file, config, statementMaker, init.classList);
146
- // console.log(init.classList);
147
- // If its fileByFile
148
- if (init["--module"] && module.trim()) {
149
- try {
150
- fs.writeFileSync(file + '.module.css', module);
151
- // console.log(content);
152
- console.log('AliasCSS compiled', path.relative('.', file), 'module Locally ');
153
- }
154
- catch (error) {
155
- console.log('\x1b[31m', "Couldn't able to append/create locally from " + file);
156
- console.log(error);
157
- }
158
- }
159
- if (init["--file"]) {
160
- try {
161
- fs.writeFileSync(file + '.css', content);
162
- postify(file + '.css', [postcssDiscardDuplicates], init.minify);
163
- // console.log(content);
164
- console.log('AliasCSS compiled', path.relative('.', file), 'Locally');
165
- }
166
- catch (error) {
167
- console.log('\x1b[31m', "Couldn't able to append/create locally from " + file);
168
- console.log(error);
169
- }
170
- }
171
- // Check for Global
172
- if (!bool && init.output) {
173
- try {
174
- fs.writeFileSync(init.output, `\n/* Start :-----------ACSS ${path.relative('.', file)}------------------------*/\n${postcss([postcssDiscardDuplicates]).process(gbContent)}
175
- \n/* End :-----------ACSS ${path.relative('.', file)}----------------------------*/\n
176
- `, { flag: 'a+' });
177
- console.log('AliasCSS compiled', path.relative('.', file), 'to main css file :' + init.output);
162
+ export function createCSSFileByFile(file_1) {
163
+ return __awaiter(this, arguments, void 0, function* (file, bool = false) {
164
+ const [gbContent, content, module] = compileFile(file, config, statementMaker, init.classList);
165
+ if (init["--module"] && module.trim()) {
166
+ try {
167
+ fs.writeFileSync(file + ".module.css", module);
168
+ console.log("AliasCSS compiled", path.relative(".", file), "module Locally ");
169
+ }
170
+ catch (error) {
171
+ console.log('\x1b[31m', "Couldn't able to append/create locally from " + file);
172
+ console.log(error);
173
+ }
178
174
  }
179
- catch (error) {
180
- console.log('\x1b[31m', "Couldn't able to append/create to main css file :" + init.output);
181
- console.log(error);
175
+ if (init["--file"]) {
176
+ try {
177
+ fs.writeFileSync(file + ".css", content);
178
+ yield postify(file + ".css", [postcssDiscardDuplicates], init.minify);
179
+ console.log("AliasCSS compiled", path.relative(".", file), "Locally");
180
+ }
181
+ catch (error) {
182
+ console.log('\x1b[31m', "Couldn't able to append/create locally from " + file);
183
+ console.log(error);
184
+ }
182
185
  }
183
- }
186
+ });
184
187
  }
185
- export function postify(file, plugin, minify = false, sort = "mobile-first") {
186
- const data = fs.readFileSync(file, 'utf-8');
187
- plugin.push(sortMediaQueries({
188
- sort
189
- }));
190
- if (fs.existsSync(file)) {
191
- if (minify === true)
192
- plugin.push(cssnano);
193
- postcss(plugin).process(data, { from: undefined }).then(result => {
194
- fs.truncateSync(file);
195
- fs.writeFileSync(file, result.css);
196
- });
197
- }
198
- // fs.readFile(file, (err, css) => {
199
- // postcss(plugin)
200
- // .process(css, { from: file, to: file+"post.css" })
201
- // .then(result => {
202
- // fs.writeFile(file+"post.css", result.css, () => true)
203
- // // if ( result.map ) {
204
- // // fs.writeFile(file+'.map', result.map.toString(), () => true)
205
- // // }
206
- // })
207
- // })
188
+ export function postify(file_1, plugin_1) {
189
+ return __awaiter(this, arguments, void 0, function* (file, plugin, minify = false, sort = "mobile-first") {
190
+ if (!fs.existsSync(file))
191
+ return;
192
+ const data = fs.readFileSync(file, "utf-8");
193
+ const plugins = [...plugin, sortMediaQueries({ sort })];
194
+ if (minify)
195
+ plugins.push(cssnano);
196
+ const result = yield postcss(plugins).process(data, { from: undefined });
197
+ fs.writeFileSync(file, result.css);
198
+ });
208
199
  }
209
200
  export function writeStatementToFile(file, content, from) {
210
- // Check for Global
211
201
  if (init.output) {
212
202
  try {
213
- fs.writeFileSync(init.output, `\n/* Start :-----------ACSS:From aliasCSSConfig.${from}------------------------*/\n${content}
214
- \n/* End :-----------ACSS aliasCSSConfig.${from}----------------------------*/\n
215
- `, { flag: 'a+' });
216
- console.log('AliasCSS compiled', '[aliasCSSConfig.statement]', 'aliascss.config.js');
203
+ fs.writeFileSync(init.output, `\n/* Start :-----------ACSS:From aliasCSSConfig.${from}------------------------*/\n${content}\n/* End :-----------ACSS aliasCSSConfig.${from}----------------------------*/\n`, { flag: "a+" });
204
+ console.log("AliasCSS compiled", `[aliasCSSConfig.${from}]`, "aliascss.config.js");
217
205
  }
218
206
  catch (error) {
219
- console.log('\x1b[31m', "Couldn't able to append/create [key:statement] from alias.config.js ");
207
+ console.log('\x1b[31m', `Couldn't able to append/create [key:${from}] from alias.config.js`);
220
208
  console.log(error);
221
209
  }
222
210
  }
223
211
  }
224
- // Initialize
225
212
  export function initialize(configFile) {
226
- // ----------------input-------------------
227
- if (configFile.hasOwnProperty('input')) {
213
+ if (configFile.hasOwnProperty("input")) {
228
214
  init.input = configFile.input;
229
215
  init.globPattern = configFile.input;
230
216
  }
231
- // ----------------input-------------------
232
- if (configFile.hasOwnProperty('layers') && Array.isArray(configFile.layers)) {
217
+ if (configFile.hasOwnProperty("layers") && Array.isArray(configFile.layers)) {
233
218
  init.layers = configFile.layers;
234
219
  }
235
220
  else {
236
221
  init.layers = config.layers;
237
222
  }
238
- // ----------------Prefix-------------------
239
- if (configFile.hasOwnProperty('prefix')) {
223
+ if (configFile.hasOwnProperty("prefix")) {
240
224
  init.config.prefix = configFile.prefix;
241
225
  }
242
- // ----------------output-------------------
243
- if (configFile.hasOwnProperty('output')) {
226
+ if (configFile.hasOwnProperty("output")) {
244
227
  const op = configFile.output;
245
- if (op.hasOwnProperty('location')) {
228
+ if (op.hasOwnProperty("location"))
246
229
  init.output = op.location;
247
- }
248
- if (op.hasOwnProperty('--file') && op['--file'] === true) {
230
+ if (op.hasOwnProperty("--file") && op["--file"] === true)
249
231
  init["--file"] = true;
250
- }
251
232
  }
252
- // Adding Custom color, length etc
253
- if (configFile.hasOwnProperty('custom') && typeof configFile.custom === 'object') {
233
+ if (configFile.hasOwnProperty("custom") && typeof configFile.custom === "object") {
254
234
  Object.keys(configFile.custom).forEach((key) => {
255
235
  init.statementMaker.addCustom(key, configFile.custom[key]);
256
236
  });
257
237
  }
258
- // Extend custom class name define {'border-color-native":'border-color: skyBlue',}
259
- if (configFile.hasOwnProperty('prebuild')) {
238
+ if (configFile.hasOwnProperty("prebuild")) {
260
239
  init.statementMaker.prebuild(configFile.prebuild);
261
240
  }
262
- // Ignore these class name
263
- if (configFile.hasOwnProperty('ignore')) {
264
- if (Array.isArray(configFile.ignore)) {
265
- configFile.ignore.forEach((each) => init.config.ignore.push(each.trim()));
266
- }
241
+ if (configFile.hasOwnProperty("ignore") && Array.isArray(configFile.ignore)) {
242
+ configFile.ignore.forEach((each) => init.config.ignore.push(each.trim()));
267
243
  }
268
- // --module
269
- if (configFile.hasOwnProperty('--module') && configFile.hasOwnProperty('importModuleAs')) {
244
+ if (configFile.hasOwnProperty("--module") && configFile.hasOwnProperty("importModuleAs")) {
270
245
  init["--module"] = true;
271
- init.config.useCSSModule = init["--module"] ? true : false;
272
- if (init.config.useCSSModule)
273
- init.config.matchCSSModuleFunction = init.config.createCSSModuleRegex(configFile.importModuleAs);
246
+ init.config.useCSSModule = true;
247
+ init.config.matchCSSModuleFunction = init.config.createCSSModuleRegex(configFile.importModuleAs);
274
248
  }
275
- // ---------output Minify
276
- if (configFile.hasOwnProperty('minify')) {
249
+ if (configFile.hasOwnProperty("minify")) {
277
250
  init.minify = configFile.minify;
278
251
  }
279
- // ------------Extractor function-------
280
- if (configFile.hasOwnProperty('extractorFunction')) {
252
+ if (configFile.hasOwnProperty("extractorFunction")) {
281
253
  init.config.useExtractorFunction = configFile.extractorFunction.trim() ? true : false;
282
254
  if (init.config.useExtractorFunction)
283
255
  init.config.matchExtractorFunction = init.config.createExtractorRegex(configFile.extractorFunction);
284
256
  }
285
257
  else {
286
258
  init.config.useExtractorFunction = true;
287
- init.config.matchExtractorFunction = init.config.createExtractorRegex('String');
259
+ init.config.matchExtractorFunction = init.config.createExtractorRegex("String");
288
260
  }
289
- // ---------Extend----------------
290
- if (configFile.hasOwnProperty('extend') && typeof configFile.extend === 'object') {
291
- const filteredObj = {};
292
- Object.keys(configFile.extend).map((key) => {
293
- // if (configFile.extend[key].hasOwnProperty('compiler') && (typeof configFile.extend[key].compiler === 'function')){
294
- filteredObj[key] = configFile.extend[key];
295
- // }
296
- });
297
- init.statementMaker.extend(filteredObj);
261
+ if (configFile.hasOwnProperty("extend") && typeof configFile.extend === "object") {
262
+ init.statementMaker.extend(configFile.extend);
298
263
  }
299
- // -----------------useColon----------------------------
300
- if (configFile.hasOwnProperty('useColon')) {
264
+ if (configFile.hasOwnProperty("useColon")) {
301
265
  init.config.useColon = configFile.useColon;
302
266
  }
303
- // ---------------addMedia----------------
304
- if (configFile.hasOwnProperty('media') && typeof configFile.media === 'object') {
267
+ if (configFile.hasOwnProperty("media") && typeof configFile.media === "object") {
305
268
  init.statementMaker.addMedia(configFile.media);
306
269
  }
307
- // /Truncate File every time we bundle
308
- if (configFile.hasOwnProperty('truncate') && configFile.truncate === false) {
309
- // do nothing
310
- }
311
- else {
312
- if (fs.existsSync(init.output))
313
- fs.truncateSync(path.resolve(init.output));
314
- writeStatementToFile(init.output, `@layer ${init.layers.join(', ')};`, 'Initializating @layer,');
315
- }
316
- // Custom CSS statement
317
- if (configFile.hasOwnProperty('statement')) {
270
+ if (configFile.hasOwnProperty("statement")) {
318
271
  init.rawCSS = configFile.statement;
319
272
  init.statementMaker.rawCSS = configFile.statement;
320
- writeStatementToFile(init.output, configFile.statement, 'config.statement');
321
273
  }
322
- // Custom Groups bundling acss classnames in single class name
323
- if (configFile.hasOwnProperty('group')) {
274
+ if (configFile.hasOwnProperty("group")) {
324
275
  init.customGroupStatement = init.statementMaker.groupObj(configFile.group);
325
276
  init.statementMaker.customGroupStatement = init.statementMaker.groupObj(configFile.group);
326
- if (init.customGroupStatement)
327
- writeStatementToFile(init.output, init.customGroupStatement, 'config.group');
328
277
  }
329
278
  }
330
- // ----------------WATCH-------------------------------
331
279
  export function watch(config) {
332
280
  main(config);
333
281
  const watcher = chokidar.watch(init.input, {
334
- ignored: '*.css', // ignore dot-files
335
- persistent: true
282
+ ignored: "*.css",
283
+ persistent: true,
336
284
  });
337
- const compileFile = (file) => {
285
+ const compileFile = (file) => __awaiter(this, void 0, void 0, function* () {
338
286
  console.log(`--processing file : ${file}`);
339
- createCSSFileByFile(file, true);
340
- globalCSSCompiler();
341
- postify(init.output, [postcssDiscardDuplicates], init.minify);
342
- console.log('Done! ');
343
- };
344
- // Something to use when events are received.
287
+ yield createCSSFileByFile(file, true);
288
+ yield globalCSSCompiler();
289
+ console.log("Done! ");
290
+ });
345
291
  const log = console.log.bind(console);
346
- // Add event listeners.
347
292
  watcher
348
- .on('add', path => log(`File ${path} has been added to watch`))
349
- .on('change', path => compileFile(path));
350
- // .on('unlink', path => log(`File ${path} has been removed`));
351
- // More possible events.
352
- watcher
353
- .on('addDir', path => log(`Directory ${path} has been added`))
354
- .on('unlinkDir', path => log(`Directory ${path} has been removed`))
355
- // .on('error', error => log(`Watcher error: ${error}`))
356
- // .on('ready', () => log('Initial scan complete. Ready for changes'))
357
- .on('raw', (event, path, details) => {
358
- // log('Raw event info:', event, path, details);
359
- if (event === 'created' && details.type === 'file') {
293
+ .on("add", (path) => log(`File ${path} has been added to watch`))
294
+ .on("change", (path) => compileFile(path))
295
+ .on("addDir", (path) => log(`Directory ${path} has been added`))
296
+ .on("unlinkDir", (path) => log(`Directory ${path} has been removed`))
297
+ .on("raw", (event, path, details) => {
298
+ if (event === "created" && details.type === "file") {
360
299
  if (init.globPattern) {
361
300
  const files = fg.sync(init.globPattern, { absolute: true });
362
- if (files.indexOf(path) !== -1) {
301
+ if (files.indexOf(path) !== -1)
363
302
  watcher.add(path);
364
- // console.log(path,123123);
365
- }
366
303
  }
367
304
  else {
368
305
  watcher.add(path);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aliascss",
3
- "version": "1.4.3",
3
+ "version": "1.4.5",
4
4
  "description": "AliasCSS is a CSS post processor.",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",