Skip to content

Commit

Permalink
feat: prevent process exit when no SCSS files are found
Browse files Browse the repository at this point in the history
  • Loading branch information
oscarmarina committed Nov 27, 2024
1 parent ee92706 commit 803b6cf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
18 changes: 8 additions & 10 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,20 +226,23 @@ export class SassStyleTemplate {

/**
* Watches for changes in SASS files and processes them.
* @param {string} glob - The glob pattern for SASS files.
* @param {string | string[]} glob - The glob pattern for SASS files.
*/
watchSass(glob) {
const watcher = chokidar.watch(glob, {ignoreInitial: true});

watcher.on('change', () => {
console.log('in');
this.globSassFile(this.renderStylesTemplate);
});

watcher.on('add', () => {
console.log('add');
this.updateGlob();
});

watcher.on('unlink', (filePath) => {
console.log('unlink');
this.updateGlob();
this.unlinkFile(filePath);
});
Expand Down Expand Up @@ -272,6 +275,7 @@ export class SassStyleTemplate {
*/
globSassFile(cb) {
this.globFiles.forEach((file) => {
console.log('sass');
cb.call(this, file);
});
}
Expand All @@ -280,14 +284,8 @@ export class SassStyleTemplate {
* Initializes the SASS style template processing.
*/
init() {
if (this.globFiles && this.globFiles.length > 0) {
this.watchSass(this.globFiles);
this.globSassFile(this.renderStylesTemplate);
} else {
console.info(
`${color.BrightCyan}[sass]${color.grey} No SASS files found to process. ${color.reset}`
);
process.exit(0);
}
const globFiles = this.globFiles && this.globFiles.length > 0 ? this.globFiles : [];
this.watchSass(globFiles);
this.globSassFile(this.renderStylesTemplate);
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@blockquote/sass-style-template",
"version": "4.0.1",
"version": "4.0.2",
"description": "A SCSS watcher with autoprefixer for building Web Components using Lit and SASS.",
"keywords": [
"lit",
Expand Down

0 comments on commit 803b6cf

Please sign in to comment.