Skip to content

Commit

Permalink
Refined conditions for final logs in API methods
Browse files Browse the repository at this point in the history
  • Loading branch information
adamlui committed Jun 11, 2024
1 parent 220c608 commit 9df06de
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions minify.js/node.js/src/minify.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function findJS(searchDir, options = {}) {
});

// Log/return final result
if (!options.isRecursing && options.verbose) {
if (options.verbose && !options.isRecursing) {
console.info('findJS() » Search complete! '
+ ( jsFiles.length == 0 ? 'No' : jsFiles.length )
+ ` file${ jsFiles.length == 1 ? '' : 's' } found.`);
Expand Down Expand Up @@ -106,7 +106,7 @@ function minify(input, options = {}) {
const minifyResult = uglifyJS.minify(fs.readFileSync(input, 'utf8'), minifyOptions);
if (options.comment) minifyResult.code = prependComment(minifyResult.code, options.comment);
if (minifyResult.error) console.error(`minify() » ERROR: ${minifyResult.error.message}`);
else if (typeof window != 'undefined')
else if (options.verbose && typeof window != 'undefined')
console.info('minify() » Minification complete! Check returned object.');
return { code: minifyResult.code, srcPath: path.resolve(process.cwd(), input),
error: minifyResult.error };
Expand All @@ -123,7 +123,7 @@ function minify(input, options = {}) {
return { code: minifyResult.code, srcPath: jsPath, error: minifyResult.error };
}).filter(data => !data.error); // filter out failed minifications
if (options.verbose) {
if (minifyResult.length > 0) console.info(
if (minifyResult.length > 0 && typeof window != 'undefined') console.info(
'minify() » Minification complete! Check returned object.');
else console.info(
'minify() » No unminified JavaScript files processed.');
Expand Down
4 changes: 2 additions & 2 deletions scss-to-css/node.js/src/scss-to-css.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ function findSCSS(searchDir, options = {}) {
});

// Log/return final result
if (!options.isRecursing && options.verbose) {
if (options.verbose && !options.isRecursing) {
console.info('findSCSS() » Search complete! '
+ ( scssFiles.length == 0 ? 'No' : scssFiles.length )
+ ` file${ scssFiles.length == 1 ? '' : 's' } found.`);
Expand Down Expand Up @@ -128,7 +128,7 @@ function compile(input, options = {}) {
}
}).filter(data => !data.error ); // filter out failed compilations
if (options.verbose) {
if (compileResult.length > 0) console.info(
if (compileResult.length > 0 && typeof window != 'undefined') console.info(
'compile() » Compilation complete! Check returned object.');
else console.info(
'compile() » No SCSS files processed.');
Expand Down

0 comments on commit 9df06de

Please sign in to comment.