Skip to content

Commit

Permalink
Moved compilation summary before write routine + added return on no w…
Browse files Browse the repository at this point in the history
…ritable data ↞ [auto-sync from `adamlui/js-utils`]
  • Loading branch information
adamlui authored and kudo-sync-bot committed May 14, 2024
1 parent 6df57cf commit f78d847
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions node.js/src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,22 @@ else if (process.argv.some(arg => reArgs.infoCmds.version.test(arg))) {
return compileResult;
}).filter(data => !data.error ); // filter out failed compilations

// Print compilation summary
if (compileData?.length > 0) {
const cssCntSuffix = compileData.length > 1 ? 's' : '';
printIfNotQuiet(`\n${bg}Compilation complete!${nc}`);
printIfNotQuiet(`${bw + compileData.length} CSS file${ cssCntSuffix }`
+ ( !config.noSourceMaps ? ` + ${compileData.length} source map${ cssCntSuffix }` : '' )
+ ' generated.' + nc);
} else printIfNotQuiet(`\n${by}No SCSS files processed.${nc}`);
if (failedPaths.length > 0) {
printIfNotQuiet(`\n${br}`
+ `${failedPaths.length} file${ failedPaths.length > 1 ? 's' : '' }`
+ ` failed to compile:${nc}`);
failedPaths.forEach(path => printIfNotQuiet(path));
}
if (compileData?.length == 0) return;

// Write array data to files
printIfNotQuiet(`\nWriting to file${ compileData?.length > 1 ? 's' : '' }...`);
compileData?.forEach(({ code, srcMap, srcPath }) => {
Expand All @@ -140,21 +156,6 @@ else if (process.argv.some(arg => reArgs.infoCmds.version.test(arg))) {
fs.writeFileSync(outputPath, code, 'utf8');
if (!config.noSourceMaps) fs.writeFileSync(outputPath + '.map', JSON.stringify(srcMap), 'utf8');
});

// Print final summary
if (compileData?.length > 0) {
const cssCntSuffix = compileData.length > 1 ? 's' : '';
printIfNotQuiet(`\n${bg}Compilation complete!${nc}`);
printIfNotQuiet(`${bw + compileData.length} CSS file${ cssCntSuffix }`
+ ( !config.noSourceMaps ? ` + ${compileData.length} source map${ cssCntSuffix }` : '' )
+ ' generated.' + nc);
} else printIfNotQuiet(`\n${by}No SCSS files processed.${nc}`);
if (failedPaths.length > 0) {
printIfNotQuiet(`\n${br}`
+ `${failedPaths.length} file${ failedPaths.length > 1 ? 's' : '' }`
+ ` failed to compile:${nc}`);
failedPaths.forEach(path => printIfNotQuiet(path));
}
}
}

Expand Down

0 comments on commit f78d847

Please sign in to comment.