Comparing version 0.1.13 to 0.1.14
const path = require('path'); | ||
const console = require('console'); | ||
const chokidar = require('chokidar'); | ||
const minimatch = require('minimatch'); | ||
const {promisify} = require('util'); | ||
@@ -9,3 +10,3 @@ const glob = promisify(require('glob')); | ||
const listFiles = async (patterns) => { | ||
const listFiles = async ({include, exclude}) => { | ||
const options = { | ||
@@ -15,4 +16,10 @@ nodir: true, | ||
}; | ||
const results = await Promise.all(patterns.map((pattern) => glob(pattern, options))); | ||
return [].concat(...results); | ||
const results = await Promise.all(include.map((pattern) => glob(pattern, options))); | ||
const concatenated = [].concat(...results); | ||
if (exclude) { | ||
const excludePatterns = [].concat(exclude); | ||
return concatenated.filter((file) => excludePatterns.every((pattern) => !minimatch(file, pattern))); | ||
} else { | ||
return concatenated; | ||
} | ||
}; | ||
@@ -179,4 +186,4 @@ | ||
const getConfig = async (options) => { | ||
if (options.patterns && options.patterns.length === 0) { | ||
delete options.patterns; | ||
if (options.include && options.include.length === 0) { | ||
delete options.include; | ||
} | ||
@@ -195,8 +202,8 @@ const configFile = options.config | ||
config.generateDefinition = getGenerator(config); | ||
const patterns = [].concat(config.patterns).filter(Boolean).map((x) => x.split(path.sep).join('/')); | ||
if (patterns.length === 0) { | ||
patterns.push('**/*.css'); | ||
const include = [].concat(config.include).filter(Boolean).map((x) => x.split(path.sep).join('/')); | ||
if (include.length === 0) { | ||
include.push('**/*.css'); | ||
} | ||
config.patterns = patterns; | ||
config.files = await listFiles(patterns); | ||
config.include = include; | ||
config.files = await listFiles(config); | ||
return config; | ||
@@ -216,3 +223,3 @@ }; | ||
const config = await start(options); | ||
const watcher = chokidar.watch(config.patterns, Object.assign({}, config.chokidar)); | ||
const watcher = chokidar.watch(config.include, Object.assign({}, config.chokidar)); | ||
const output = config.dest | ||
@@ -219,0 +226,0 @@ ? () => { |
{ | ||
"name": "esifycss", | ||
"version": "0.1.13", | ||
"version": "0.1.14", | ||
"description": "Generates .js or .ts exports class names and custom properties", | ||
@@ -24,2 +24,3 @@ "author": { | ||
"glob": "^7.1.3", | ||
"minimatch": "^3.0.4", | ||
"postcss": "^7.0.5" | ||
@@ -26,0 +27,0 @@ }, |
Sorry, the diff of this file is not supported yet
15787
239
6
+ Addedminimatch@^3.0.4