@adamlui/scss-to-css 1.8.5 → 1.9.0

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.
package/README.md CHANGED
@@ -29,7 +29,7 @@
29
29
 
30
30
  <a href="https://www.npmjs.com/package/@adamlui/scss-to-css"><img height=31 src="https://img.shields.io/npm/dm/%40adamlui%2Fscss-to-css?logo=npm&color=af68ff&logoColor=white&labelColor=464646&style=for-the-badge"></a>
31
31
  <a href="#%EF%B8%8F-mit-license"><img height=31 src="https://img.shields.io/badge/License-MIT-orange.svg?logo=internetarchive&logoColor=white&labelColor=464646&style=for-the-badge"></a>
32
- <a href="https://github.com/adamlui/js-utils/releases/tag/scss-to-css-1.8.5"><img height=31 src="https://img.shields.io/badge/Latest_Build-1.8.5-44cc11.svg?logo=icinga&logoColor=white&labelColor=464646&style=for-the-badge"></a>
32
+ <a href="https://github.com/adamlui/js-utils/releases/tag/scss-to-css-1.9.0"><img height=31 src="https://img.shields.io/badge/Latest_Build-1.9.0-44cc11.svg?logo=icinga&logoColor=white&labelColor=464646&style=for-the-badge"></a>
33
33
  <a href="https://www.npmjs.com/package/@adamlui/scss-to-css?activeTab=code"><img height=31 src="https://img.shields.io/npm/unpacked-size/%40adamlui%2Fscss-to-css?style=for-the-badge&logo=ebox&logoColor=white&color=blue&labelColor=464646"></a>
34
34
  <a href="https://sonarcloud.io/component_measures?metric=new_vulnerabilities&id=adamlui_scss-to-css:node.js/src/scss-to-css.js"><img height=31 src="https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fsonarcloud.io%2Fapi%2Fmeasures%2Fcomponent%3Fcomponent%3Dadamlui_scss-to-css%3Anode.js%2Fsrc%2Fscss-to-css.js%26metricKeys%3Dvulnerabilities&query=%24.component.measures.0.value&style=for-the-badge&logo=sonarcloud&logoColor=white&labelColor=464646&label=Vulnerabilities&color=gold"></a>
35
35
  <a href="https://github.com/toolleeo/cli-apps#conversion"><img height=31 src="https://img.shields.io/badge/Mentioned_in-Awesome-c4a2bd?logo=awesomelists&logoColor=white&labelColor=464646&style=for-the-badge"></a>
@@ -134,7 +134,7 @@ $ scss-to-css input_folder output_folder
134
134
  ### Command line options
135
135
 
136
136
  ```
137
- Config options:
137
+ Boolean options:
138
138
  -n, --dry-run Don't actually compile the file(s), just
139
139
  show if they will be processed.
140
140
  -d, --include-dotfolders Include dotfolders in file search.
@@ -143,6 +143,11 @@ Config options:
143
143
  -R, --no-recursion Disable recursive file searching.
144
144
  -q, --quiet Suppress all logging except errors.
145
145
 
146
+ Parameter options:
147
+ --ignore-files="file1.scss,file2.scss" Files to exclude from
148
+ compilation.
149
+ --comment="comment" Prepend comment to compiled CSS.
150
+ Separate by line using '\n'.
146
151
  Info commands:
147
152
  -h, --help Display help screen.
148
153
  -v, --version Show version number.
@@ -208,13 +213,15 @@ scssToCSS.compile(inputDir, { minify: false });
208
213
 
209
214
  Available parameters (and their default settings) are:
210
215
 
211
- Name | Desciption | Default value
212
- -------------|---------------------------------------------------------|---------------
213
- `recursive` | Recursively search for nested files if dir path passed. | `true`
214
- `verbose` | Show logging in console/terminal. | `true`
215
- `dotFolders` | Include dotfolders in file search. | `false`
216
- `minify` | Minify output CSS. | `true`
217
- `sourceMaps` | Generate CSS source maps. | `true`
216
+ Name | Type | Desciption | Default value
217
+ --------------|---------|------------------------------------------------------------------|---------------
218
+ `recursive` | Boolean | Recursively search for nested files if dir path passed. | `true`
219
+ `verbose` | Boolean | Show logging in console/terminal. | `true`
220
+ `dotFolders` | Boolean | Include dotfolders in file search. | `false`
221
+ `minify` | Boolean | Minify output CSS. | `true`
222
+ `sourceMaps` | Boolean | Generate CSS source maps. | `true`
223
+ `ignoreFiles` | Array | Files (by name) to exclude from compilation. | `[]`
224
+ `comment` | String | Comment to prepend to compiled CSS. Separate by line using '\n'. | `''`
218
225
 
219
226
  #
220
227
 
@@ -243,11 +250,12 @@ findSCSS() » Check returned array.
243
250
 
244
251
  Available parameters (and their default settings) are:
245
252
 
246
- Name | Desciption | Default value
247
- -------------|----------------------------------------------------------|---------------
248
- `recursive` | Recursively search for nested files in searchDir passed. | `true`
249
- `verbose` | Show logging in console/terminal. | `true`
250
- `dotFolders` | Include dotfolders in file search. | `false`
253
+ Name | Type | Desciption | Default value
254
+ --------------|---------|----------------------------------------------------------|---------------
255
+ `recursive` | Boolean | Recursively search for nested files in searchDir passed. | `true`
256
+ `verbose` | Boolean | Show logging in console/terminal. | `true`
257
+ `dotFolders` | Boolean | Include dotfolders in file search. | `false`
258
+ `ignoreFiles` | Array | Files (by name) to exclude from search results. | `[]`
251
259
 
252
260
  <br>
253
261
 
package/dist/cli.min.js CHANGED
@@ -4,23 +4,25 @@
4
4
  * Source: https://code.scsstocss.org/node.js
5
5
  * Documentation: https://docs.scsstocss.org/node.js
6
6
  */
7
- const pkgName="@adamlui/scss-to-css",copyright="© 2024 Adam Lui & contributors under the MIT license.",cmdFormat="scss-to-css [inputPath] [outputPath] [options]",srcURL="https://code.scsstocss.org/node.js",docURL="https://docs.scsstocss.org/node.js/#-command-line-usage",scssToCSS=require(__dirname.match(/src/)?"./scss-to-css":"./scss-to-css.min"),fs=require("fs"),path=require("path"),execSync=require("child_process")["execSync"],nc="",br="",by="",bg="",bw="",config={},reArgs={dryRun:/^--?(?:n|dry-?run)$/,includeDotFolders:/^--?(?:dd?|(?:include-?)?dot-?(?:folder|dir(?:ector(?:y|ie))?)s?=?(?:true|1)?)$/,noSourceMaps:/^--?(?:S|(?:exclude|disable|no)-?so?u?rce?-?maps?|so?u?rce?-?maps?=(?:false|0))$/,noRecursion:/^--?(?:R|(?:disable|no)-?recursi(?:on|ve)|recursi(?:on|ve)=(?:false|0))$/,noMinify:/^--?(?:M|(?:disable|no)-?minif(?:y|ication)|minif(?:y|ication)=(?:false|0))$/,quietMode:/^--?q(?:uiet)?(?:-?mode)?$/,help:/^--?h(?:elp)?$/,version:/^--?ve?r?s?i?o?n?$/};if(process.argv.forEach(s=>{var e;s.startsWith("-")&&((e=Object.keys(reArgs).find(e=>reArgs[e].test(s)))?config[e]=!0:(console.error(`
7
+ const pkgName="@adamlui/scss-to-css",copyright="© 2024 Adam Lui & contributors under the MIT license.",cmdFormat="scss-to-css [inputPath] [outputPath] [options]",srcURL="https://code.scsstocss.org/node.js",docURL="https://docs.scsstocss.org/node.js/#-command-line-usage",scssToCSS=require(__dirname.match(/src/)?"./scss-to-css":"./scss-to-css.min"),fs=require("fs"),path=require("path"),execSync=require("child_process")["execSync"],nc="",br="",by="",bg="",bw="",config={},reArgs={flags:{dryRun:/^--?(?:n|dry-?run)$/,includeDotFolders:/^--?(?:dd?|(?:include-?)?dot-?(?:folder|dir(?:ector(?:y|ie))?)s?=?(?:true|1)?)$/,noSourceMaps:/^--?(?:S|(?:exclude|disable|no)-?so?u?rce?-?maps?|so?u?rce?-?maps?=(?:false|0))$/,noRecursion:/^--?(?:R|(?:disable|no)-?recursi(?:on|ve)|recursi(?:on|ve)=(?:false|0))$/,noMinify:/^--?(?:M|(?:disable|no)-?minif(?:y|ication)|minif(?:y|ication)=(?:false|0))$/,quietMode:/^--?q(?:uiet)?(?:-?mode)?$/},paramOptions:{ignoreFiles:/^--?(?:ignore|skip|exclude)(?:d?-?files?)?(?:=.*|$)/,comment:/^--?comments?(?:=.*|$)/},infoCmds:{help:/^--?h(?:elp)?$/,version:/^--?ve?r?s?i?o?n?$/}};if(process.argv.forEach(s=>{var e,o,n;s.startsWith("-")&&(n=Object.keys(reArgs.flags).find(e=>reArgs.flags[e].test(s)),e=Object.keys(reArgs.paramOptions).find(e=>reArgs.paramOptions[e].test(s)),o=Object.keys(reArgs.infoCmds).find(e=>reArgs.infoCmds[e].test(s)),n?config[n]=!0:e?(/=.+/.test(s)||(console.error(`
8
+ ${br}ERROR: Arg [--${s.replace(/-/g,"")}] requires '=' followed by a value.`+nc),printHelpCmdAndDocURL(),process.exit(1)),n=s.split("=")[1],config[e]=parseInt(n)||n):o||(console.error(`
8
9
  ${br}ERROR: Arg [${s}] not recognized.`+nc),console.info(`
9
- ${by}Valid arguments are below.`+nc),printHelpSections(["configOptions","infoCmds"]),process.exit(1)))}),process.argv.some(e=>reArgs.help.test(e)))printHelpSections();else if(process.argv.some(e=>reArgs.version.test(e))){const f=execSync(`npm view ${pkgName} version`).toString().trim()||"none";let e,s=process.cwd();for(;"/"!=s;){const i=path.join(s,"package.json");if(fs.existsSync(i)){const j=require(i);e=(j.dependencies?.[pkgName]||j.devDependencies?.[pkgName])?.match(/(\d+\.\d+\.\d+)/)[0]||"none";break}s=path.dirname(s)}console.info(`
10
- Global version: `+f),console.info("Local version: "+e)}else{const[k="",l=""]=process.argv.slice(2).filter(e=>!e.startsWith("-")).map(e=>e.replace(/^\/*/,"")),m=path.resolve(process.cwd(),k),n=(k&&!fs.existsSync(m)&&(console.error(`
10
+ ${by}Valid arguments are below.`+nc),printHelpSections(["flags","paramOptions","infoCmds"]),process.exit(1)))}),process.argv.some(e=>reArgs.infoCmds.help.test(e)))printHelpSections();else if(process.argv.some(e=>reArgs.infoCmds.version.test(e))){const k=execSync(`npm view ${pkgName} version`).toString().trim()||"none";let e,s=process.cwd();for(;"/"!=s;){const n=path.join(s,"package.json");if(fs.existsSync(n)){const o=require(n);e=(o.dependencies?.[pkgName]||o.devDependencies?.[pkgName])?.match(/(\d+\.\d+\.\d+)/)[0]||"none";break}s=path.dirname(s)}console.info(`
11
+ Global version: `+k),console.info("Local version: "+e)}else{const[p="",q=""]=process.argv.slice(2).filter(e=>!e.startsWith("-")).map(e=>e.replace(/^\/*/,"")),r=path.resolve(process.cwd(),p),s=(p&&!fs.existsSync(r)&&(console.error(`
11
12
  ${br}Error: First argument can only be an existing file or directory.`+`
12
- '${m}' does not exist.`+nc+`
13
+ '${r}' does not exist.`+nc+`
13
14
 
14
15
  ${bg}Example valid command:
15
- » scss-to-css . output.min.css`+nc),printHelpCmdAndDocURL(),process.exit(1)),k.endsWith(".scss")?[m]:scssToCSS.findSCSS(m,{recursive:!config.noRecursion,verbose:!config.quietMode}));if(config.dryRun)0<n.length?(console.info(`
16
- ${by}SCSS files to be compiled:`+nc),n.forEach(e=>console.info(e))):console.info(by+`
17
- No SCSS files will be compiled.`+nc);else{const r=[],s=n.map(e=>{var s=scssToCSS.compile(e,{minify:!config.noMinify,sourceMaps:!config.noSourceMaps,verbose:!config.quietMode});return s.error&&r.push(e),s}).filter(e=>!e.error);if(s?.forEach(({code:e,srcMap:s,srcPath:o})=>{var n=path.join(path.dirname(o),/(?:src|s[ac]ss)$/.test(path.dirname(o))?"../"+(l||"css"):l.endsWith(".css")?path.dirname(l):l||"css"),o=(l.endsWith(".css")&&k.endsWith(".scss")?path.basename(l).replace(/(\.min)?\.css$/,""):path.basename(o,".scss"))+".min.css",o=path.join(n,o);fs.existsSync(n)||fs.mkdirSync(n,{recursive:!0}),fs.writeFileSync(o,e,"utf8"),config.noSourceMaps||fs.writeFileSync(o+".map",JSON.stringify(s),"utf8")}),0<s?.length){const C=1<s.length?"s":"";printIfNotQuiet(`
18
- ${bg}Compilation complete!`+nc),printIfNotQuiet(bw+s.length+" CSS file"+C+(config.noSourceMaps?"":` + ${s.length} source map`+C)+" generated."+nc)}else printIfNotQuiet(by+"No SCSS files processed."+nc);0<r.length&&(printIfNotQuiet(`
19
- `+br+r.length+" file"+(1<r.length?"s":"")+" failed to compile:"+nc),r.forEach(e=>printIfNotQuiet(e)))}}function printHelpSections(e=["header","usage","pathArgs","configOptions","infoCmds"]){var s=` ${pkgName.replace(/^@[^/]+\//,"")} ${nc} `;const o={header:[`
16
+ » scss-to-css . output.min.css`+nc),printHelpCmdAndDocURL(),process.exit(1)),p.endsWith(".scss")?[r]:scssToCSS.findSCSS(r,{recursive:!config.noRecursion,verbose:!config.quietMode,ignoreFiles:(config.ignoreFiles?.split(",")??[]).map(e=>e.trim())}));if(config.dryRun)0<s.length?(console.info(`
17
+ ${by}SCSS files to be compiled:`+nc),s.forEach(e=>console.info(e))):console.info(by+`
18
+ No SCSS files will be compiled.`+nc);else{const x=[],y=s.map(e=>{var s=scssToCSS.compile(e,{verbose:!config.quietMode,minify:!config.noMinify,sourceMaps:!config.noSourceMaps,comment:config.comment?.replace(/\\n/g,"\n")});return s.error&&x.push(e),s}).filter(e=>!e.error);if(y?.forEach(({code:e,srcMap:s,srcPath:o})=>{var n=path.join(path.dirname(o),/(?:src|s[ac]ss)$/.test(path.dirname(o))?"../"+(q||"css"):q.endsWith(".css")?path.dirname(q):q||"css"),o=(q.endsWith(".css")&&p.endsWith(".scss")?path.basename(q).replace(/(\.min)?\.css$/,""):path.basename(o,".scss"))+".min.css",o=path.join(n,o);fs.existsSync(n)||fs.mkdirSync(n,{recursive:!0}),fs.writeFileSync(o,e,"utf8"),config.noSourceMaps||fs.writeFileSync(o+".map",JSON.stringify(s),"utf8")}),0<y?.length){const I=1<y.length?"s":"";printIfNotQuiet(`
19
+ ${bg}Compilation complete!`+nc),printIfNotQuiet(bw+y.length+" CSS file"+I+(config.noSourceMaps?"":` + ${y.length} source map`+I)+" generated."+nc)}else printIfNotQuiet(by+"No SCSS files processed."+nc);0<x.length&&(printIfNotQuiet(`
20
+ `+br+x.length+" file"+(1<x.length?"s":"")+" failed to compile:"+nc),x.forEach(e=>printIfNotQuiet(e)))}}function printHelpSections(e=["header","usage","pathArgs","flags","paramOptions","infoCmds"]){var s=` ${pkgName.replace(/^@[^/]+\//,"")} ${nc} `;const o={header:[`
20
21
  ├ `+s+copyright,s+"Source: "+srcURL],usage:[`
21
22
  ${bw}o Usage:`+nc,` ${bw}» `+(bg+cmdFormat+nc)],pathArgs:[`
22
- ${bw}o Path arguments:`+nc," [inputPath] Path to SCSS file or directory containing SCSS files to be compiled, relative to the current working directory."," [outputPath] Path to file or directory where CSS + sourcemap files will be stored, relative to original file location (if not provided, css/ is used)."],configOptions:[`
23
- ${bw}o Config options:`+nc," -n, --dry-run Don't actually compile the file(s), just show if they will be processed."," -d, --include-dotfolders Include dotfolders in file search."," -S, --no-source-maps Prevent source maps from being generated."," -M, --no-minify Disable minification of output CSS."," -R, --no-recursion Disable recursive file searching."," -q, --quiet Suppress all logging except errors."],infoCmds:[`
24
- ${bw}o Info commands:`+nc," -h, --help Display help screen."," -v, --version Show version number."]};e.forEach(t=>{o[t]?.forEach(e=>{{var n=/header|usage/.test(t)?1:29;const i=process.stdout.columns||80,r=[],s=e.match(/\S+|\s+/g);let o="";s.forEach(e=>{var s=i-(0==r.length?0:n);o.length+"| ".length+e.length>s&&(r.push(0==r.length?o:o.trimStart()),o=""),o+=e}),r.push(0==r.length?o:o.trimStart()),r.forEach((e,s)=>console.info("| "+(0==s?e:" ".repeat(n)+e)))}})}),console.info("\nFor more help, please visit: "+bw+docURL+nc)}function printHelpCmdAndDocURL(){console.info(`
23
+ ${bw}o Path arguments:`+nc," [inputPath] Path to SCSS file or directory containing SCSS files to be compiled, relative to the current working directory."," [outputPath] Path to file or directory where CSS + sourcemap files will be stored, relative to original file location (if not provided, css/ is used)."],flags:[`
24
+ ${bw}o Boolean options:`+nc," -n, --dry-run Don't actually compile the file(s), just show if they will be processed."," -d, --include-dotfolders Include dotfolders in file search."," -S, --no-source-maps Prevent source maps from being generated."," -M, --no-minify Disable minification of output CSS."," -R, --no-recursion Disable recursive file searching."," -q, --quiet Suppress all logging except errors."],paramOptions:[`
25
+ ${bw}o Parameter options:`+nc,'--ignore-files="file1.scss,file2.scss" Files to exclude from compilation.',"--comment=\"comment\" Prepend comment to compiled CSS. Separate by line using '\\n'."],infoCmds:[`
26
+ ${bw}o Info commands:`+nc," -h, --help Display help screen."," -v, --version Show version number."]};e.forEach(t=>{o[t]?.forEach(e=>{{var n=/header|usage/.test(t)?1:41;const i=process.stdout.columns||80,r=[],s=e.match(/\S+|\s+/g);let o="";s.forEach(e=>{var s=i-(0==r.length?0:n);o.length+"| ".length+e.length>s&&(r.push(0==r.length?o:o.trimStart()),o=""),o+=e}),r.push(0==r.length?o:o.trimStart()),r.forEach((e,s)=>console.info("| "+(0==s?e:" ".repeat(n)+e)))}})}),console.info("\nFor more help, please visit: "+bw+docURL+nc)}function printHelpCmdAndDocURL(){console.info(`
25
27
  For more help, type 'scss-to-css --help' or visit
26
28
  `+(bw+docURL+nc))}function printIfNotQuiet(e){config.quietMode||console.info(e)}
@@ -4,10 +4,16 @@
4
4
  * Source: https://code.scsstocss.org/node.js
5
5
  * Documentation: https://docs.scsstocss.org/node.js
6
6
  */
7
- const fs=require("fs"),path=require("path"),sass=require("sass");function findSCSS(o,r={}){var e="https://docs.scsstocss.org/node.js/#findscsssearchdir-options",s={recursive:!0,verbose:!0,dotFolders:!1};if("string"!=typeof o)console.error("findSCSS() » ERROR: 1st arg <searchDir> must be a string."),console.info("findSCSS() » For more help, please visit "+e);else{var i=path.resolve(process.cwd(),o);if(fs.existsSync(i)){if(validateOptions(r,s,e,"findSCSS('assets/scss', { verbose: false, dotFolders: true })")){r={...s,...r};const n=fs.readdirSync(o),c=[];return r.verbose&&!r.isRecursing&&console.info("findSCSS() » Searching for SCSS files..."),n.forEach(e=>{var s=path.resolve(o,e);fs.statSync(s).isDirectory()&&"node_modules"!=e&&(r.dotFolders||!e.startsWith("."))&&r.recursive?c.push(...findSCSS(s,{...r,isRecursing:!0})):e.endsWith(".scss")&&c.push(s)}),!r.isRecursing&&r.verbose&&(console.info("findSCSS() » Search complete! "+(0==c.length?"No":c.length)+` file${0==c.length||1<c.length?"s":""} found.`),"compile"==findSCSS.caller.name||/cli(?:\.min)?\.js$/.test(require.main.filename)||console.info("findSCSS() » Check returned array.")),r.isRecursing||0<c.length?c:[]}}else console.error("findSCSS() » ERROR: 1st arg <searchDir> must be an existing directory."),console.error(`findSCSS() » ${i} does not exist.`),console.info("findSCSS() » For more help, please visit "+e)}}function compile(e,o={}){var s="https://docs.scsstocss.org/node.js/#compileinput-options",r={recursive:!0,verbose:!0,dotFolders:!1,minify:!0,sourceMaps:!0};if("string"!=typeof e)console.error("compile() » ERROR: 1st arg <input> must be a string."),console.info("compile() » For more help, please visit "+s);else if(validateOptions(o,r,s,"compile('assets/scss', { recursive: false, minify: false })")){const c={style:(o={...r,...o}).minify?"compressed":"expanded",sourceMap:o.sourceMaps};if(fs.existsSync(e)){if(!e.endsWith(".scss"))return s=findSCSS(e,{recursive:o.recursive,verbose:o.verbose,dotFolders:o.dotFolders})?.map(e=>{o.verbose&&console.info(`compile() » ** Compiling ${e}...`);try{var s=sass.compile(e,c);return{code:s.css,srcMap:s.sourceMap,srcPath:e,error:void 0}}catch(e){return console.error(`
7
+ const fs=require("fs"),path=require("path"),sass=require("sass");function findSCSS(o,r={}){var e="https://docs.scsstocss.org/node.js/#findscsssearchdir-options",s={recursive:!0,verbose:!0,dotFolders:!1,ignoreFiles:[]};if("string"!=typeof o)console.error("findSCSS() » ERROR: 1st arg <searchDir> must be a string."),console.info("findSCSS() » For more help, please visit "+e);else{var i=path.resolve(process.cwd(),o);if(fs.existsSync(i)){if(validateOptions(r,s,e,"findSCSS('assets/scss', { verbose: false, dotFolders: true })")){r={...s,...r};const n=fs.readdirSync(o),c=[];return r.verbose&&!r.isRecursing&&console.info("findSCSS() » Searching for SCSS files..."),n.forEach(e=>{var s=path.resolve(o,e);fs.statSync(s).isDirectory()&&"node_modules"!=e&&r.recursive&&(r.dotFolders||!e.startsWith("."))?c.push(...findSCSS(s,{...r,isRecursing:!0})):e.endsWith(".scss")&&!r.ignoreFiles.includes(e)?c.push(s):r.verbose&&r.ignoreFiles.includes(e)&&console.info(`findSCSS() » ** ${e} ignored due to [options.ignoreFiles]`)}),!r.isRecursing&&r.verbose&&(console.info("findSCSS() » Search complete! "+(0==c.length?"No":c.length)+` file${0==c.length||1<c.length?"s":""} found.`),"compile"==findSCSS.caller.name||/cli(?:\.min)?\.js$/.test(require.main.filename)||console.info("findSCSS() » Check returned array.")),r.isRecursing||0<c.length?c:[]}}else console.error("findSCSS() » ERROR: 1st arg <searchDir> must be an existing directory."),console.error(`findSCSS() » ${i} does not exist.`),console.info("findSCSS() » For more help, please visit "+e)}}function compile(e,o={}){var s="https://docs.scsstocss.org/node.js/#compileinput-options",r={recursive:!0,verbose:!0,dotFolders:!1,minify:!0,sourceMaps:!0,ignoreFiles:[],comment:""};if("string"!=typeof e)console.error("compile() » ERROR: 1st arg <input> must be a string."),console.info("compile() » For more help, please visit "+s);else if(validateOptions(o,r,s,"compile('assets/scss', { recursive: false, minify: false })")){const t={style:(o={...r,...o}).minify?"compressed":"expanded",sourceMap:o.sourceMaps};if(fs.existsSync(e)){if(!e.endsWith(".scss"))return s=findSCSS(e,{recursive:o.recursive,verbose:o.verbose,dotFolders:o.dotFolders,ignoreFiles:o.ignoreFiles})?.map(e=>{o.verbose&&console.info(`compile() » ** Compiling ${e}...`);try{var s=sass.compile(e,t);return o.comment&&(s.css=c(s.css,o.comment)),{code:s.css,srcMap:s.sourceMap,srcPath:e,error:void 0}}catch(e){return console.error(`
8
8
  compile() » ERROR: ${e.message}
9
- `),{code:void 0,srcMap:void 0,srcPath:void 0,error:e}}}).filter(e=>!e.error),o.verbose&&(0<s.length?console.info("compile() » Compilation complete! Check returned object."):console.info("compile() » No SCSS files processed.")),s;o.verbose&&console.info(`compile() » ** Compiling ${e}...`);try{var i=sass.compile(e,c);return o.verbose&&!/cli(?:\.min)?\.js$/.test(require.main.filename)&&console.info("compile() » Compilation complete! Check returned object."),{code:i.css,srcMap:i.sourceMap,srcPath:path.resolve(process.cwd(),e),error:void 0}}catch(e){return console.error(`
9
+ `),{code:void 0,srcMap:void 0,srcPath:void 0,error:e}}}).filter(e=>!e.error),o.verbose&&(0<s.length?console.info("compile() » Compilation complete! Check returned object."):console.info("compile() » No SCSS files processed.")),s;o.verbose&&console.info(`compile() » ** Compiling ${e}...`);try{var i=sass.compile(e,t);return o.comment&&(i.css=c(i.css,o.comment)),o.verbose&&!/cli(?:\.min)?\.js$/.test(require.main.filename)&&console.info("compile() » Compilation complete! Check returned object."),{code:i.css,srcMap:i.sourceMap,srcPath:path.resolve(process.cwd(),e),error:void 0}}catch(e){return console.error(`
10
10
  compile() » ERROR: ${e.message}
11
- `),{code:void 0,srcMap:void 0,srcPath:void 0,error:e}}}else{o.verbose&&console.info("compile() » ** Compiling passed source code...");try{var n=sass.compileString(e,c);return{code:n.css,srcMap:n.sourceMap,srcPath:void 0,error:void 0}}catch(e){return console.error(`
11
+ `),{code:void 0,srcMap:void 0,srcPath:void 0,error:e}}}else{o.verbose&&console.info("compile() » ** Compiling passed source code...");try{var n=sass.compileString(e,t);return o.comment&&(n.css=c(n.css,o.comment)),{code:n.css,srcMap:n.sourceMap,srcPath:void 0,error:void 0}}catch(e){return console.error(`
12
12
  compile() » ERROR: ${e.message}
13
- `),{code:void 0,srcMap:void 0,srcPath:void 0,error:e}}}}}function validateOptions(e,s,o,r){const i=JSON.stringify(s,null,2).replace(/"([^"]+)":/g,"$1:").replace(/"/g,"'").replace(/\n\s*/g," "),n=Object.keys(s).join(", "),c=Object.keys(s).filter(e=>"boolean"==typeof s[e]),t=Object.keys(s).filter(e=>Number.isInteger(s[e]));let l="validateOptions() » ";try{l=validateOptions.caller?.name+"() » "}catch(e){}var a=r.split(",").findIndex(e=>e.trim().startsWith("{"))+1,d=(a+=["st","nd","rd"][a-1]||"th",()=>{console.info(`${l}Valid options: [ ${n} ]`),console.info(l+"If omitted, default settings are: "+i)}),p=()=>{console.info(l+"For more help, please visit "+o)};if("object"!=typeof e)return console.error(l+`ERROR: ${"0th"==a?"[O":a+" arg [o"}ptions] can only be an object of key/values.`),console.info(l+"Example valid call: "+r),d(),p(),!1;for(const f in e){if("isRecursing"!=f&&!Object.prototype.hasOwnProperty.call(s,f))return console.error(`${l}ERROR: \`${f}\` is an invalid option.`),d(),p(),!1;if(c.includes(f)&&"boolean"!=typeof e[f])return console.error(`${l}ERROR: [${f}] option can only be \`true\` or \`false\`.`),p(),!1;if(t.includes(f)&&(e[f]=parseInt(e[f],10),isNaN(e[f])||e[f]<1))return console.error(`${l}ERROR: [${f}] option can only be an integer > 0.`),p(),!1}return!0}const funcAliases={compile:["build","minify"],findSCSS:["find","Find","findscss","findScss","Findscss","FindScss","FindSCSS","search","Search"]};module.exports={compile:compile,findSCSS:findSCSS};for(const Q in funcAliases)funcAliases[Q].forEach(e=>module.exports[e]=module.exports[Q]);
13
+ `),{code:void 0,srcMap:void 0,srcPath:void 0,error:e}}}function c(e,s){var s=s.split("\n").map(e=>" * "+e).join("\n"),o=e.indexOf("#!");return 0<=o?(o=e.indexOf("\n",o)+1,e.slice(0,o)+`/**
14
+ ${s}
15
+ */
16
+ `+e.slice(o)):`/**
17
+ ${s}
18
+ */
19
+ `+e}}}function validateOptions(e,s,o,r){const i=JSON.stringify(s,null,2).replace(/"([^"]+)":/g,"$1:").replace(/"/g,"'").replace(/\n\s*/g," "),n=Object.keys(s).join(", "),c=Object.keys(s).filter(e=>"boolean"==typeof s[e]),t=Object.keys(s).filter(e=>Number.isInteger(s[e])),l=Object.keys(s).filter(e=>Array.isArray(s[e]));let a="validateOptions() » ";try{a=validateOptions.caller?.name+"() » "}catch(e){}var d=r.split(",").findIndex(e=>e.trim().startsWith("{"))+1,p=(d+=["st","nd","rd"][d-1]||"th",()=>{console.info(`${a}Valid options: [ ${n} ]`),console.info(a+"If omitted, default settings are: "+i)}),f=()=>{console.info(a+"For more help, please visit "+o)};if("object"!=typeof e)return console.error(a+`ERROR: ${"0th"==d?"[O":d+" arg [o"}ptions] can only be an object of key/values.`),console.info(a+"Example valid call: "+r),p(),f(),!1;for(const m in e){if("isRecursing"!=m&&!Object.prototype.hasOwnProperty.call(s,m))return console.error(`${a}ERROR: \`${m}\` is an invalid option.`),p(),f(),!1;if(c.includes(m)&&"boolean"!=typeof e[m])return console.error(`${a}ERROR: [${m}] option can only be \`true\` or \`false\`.`),f(),!1;if(t.includes(m)){if(e[m]=parseInt(e[m],10),isNaN(e[m])||e[m]<1)return console.error(`${a}ERROR: [${m}] option can only be an integer > 0.`),f(),!1}else if(l.includes(m))if("string"!=typeof e[m]||e[m].includes(",")){if(!Array.isArray(e[m]))return console.error(`${a}ERROR: [${m}] option can only be an array.`),f(),!1}else e[m]=[e[m]]}return!0}const funcAliases={compile:["build","Build","Compile","compress","Compress","minify","Minify"],findSCSS:["find","Find","findscss","findScss","Findscss","FindScss","FindSCSS","search","Search"]};module.exports={compile:compile,findSCSS:findSCSS};for(const Z in funcAliases)funcAliases[Z].forEach(e=>module.exports[e]=module.exports[Z]);
package/docs/README.md CHANGED
@@ -29,7 +29,7 @@
29
29
 
30
30
  <a href="https://www.npmjs.com/package/@adamlui/scss-to-css"><img height=31 src="https://img.shields.io/npm/dm/%40adamlui%2Fscss-to-css?logo=npm&color=af68ff&logoColor=white&labelColor=464646&style=for-the-badge"></a>
31
31
  <a href="#%EF%B8%8F-mit-license"><img height=31 src="https://img.shields.io/badge/License-MIT-orange.svg?logo=internetarchive&logoColor=white&labelColor=464646&style=for-the-badge"></a>
32
- <a href="https://github.com/adamlui/js-utils/releases/tag/scss-to-css-1.8.5"><img height=31 src="https://img.shields.io/badge/Latest_Build-1.8.5-44cc11.svg?logo=icinga&logoColor=white&labelColor=464646&style=for-the-badge"></a>
32
+ <a href="https://github.com/adamlui/js-utils/releases/tag/scss-to-css-1.9.0"><img height=31 src="https://img.shields.io/badge/Latest_Build-1.9.0-44cc11.svg?logo=icinga&logoColor=white&labelColor=464646&style=for-the-badge"></a>
33
33
  <a href="https://www.npmjs.com/package/@adamlui/scss-to-css?activeTab=code"><img height=31 src="https://img.shields.io/npm/unpacked-size/%40adamlui%2Fscss-to-css?style=for-the-badge&logo=ebox&logoColor=white&color=blue&labelColor=464646"></a>
34
34
  <a href="https://sonarcloud.io/component_measures?metric=new_vulnerabilities&id=adamlui_scss-to-css:node.js/src/scss-to-css.js"><img height=31 src="https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fsonarcloud.io%2Fapi%2Fmeasures%2Fcomponent%3Fcomponent%3Dadamlui_scss-to-css%3Anode.js%2Fsrc%2Fscss-to-css.js%26metricKeys%3Dvulnerabilities&query=%24.component.measures.0.value&style=for-the-badge&logo=sonarcloud&logoColor=white&labelColor=464646&label=Vulnerabilities&color=gold"></a>
35
35
  <a href="https://github.com/toolleeo/cli-apps#conversion"><img height=31 src="https://img.shields.io/badge/Mentioned_in-Awesome-c4a2bd?logo=awesomelists&logoColor=white&labelColor=464646&style=for-the-badge"></a>
@@ -134,7 +134,7 @@ $ scss-to-css input_folder output_folder
134
134
  ### Command line options
135
135
 
136
136
  ```
137
- Config options:
137
+ Boolean options:
138
138
  -n, --dry-run Don't actually compile the file(s), just
139
139
  show if they will be processed.
140
140
  -d, --include-dotfolders Include dotfolders in file search.
@@ -143,6 +143,11 @@ Config options:
143
143
  -R, --no-recursion Disable recursive file searching.
144
144
  -q, --quiet Suppress all logging except errors.
145
145
 
146
+ Parameter options:
147
+ --ignore-files="file1.scss,file2.scss" Files to exclude from
148
+ compilation.
149
+ --comment="comment" Prepend comment to compiled CSS.
150
+ Separate by line using '\n'.
146
151
  Info commands:
147
152
  -h, --help Display help screen.
148
153
  -v, --version Show version number.
@@ -208,13 +213,15 @@ scssToCSS.compile(inputDir, { minify: false });
208
213
 
209
214
  Available parameters (and their default settings) are:
210
215
 
211
- Name | Desciption | Default value
212
- -------------|---------------------------------------------------------|---------------
213
- `recursive` | Recursively search for nested files if dir path passed. | `true`
214
- `verbose` | Show logging in console/terminal. | `true`
215
- `dotFolders` | Include dotfolders in file search. | `false`
216
- `minify` | Minify output CSS. | `true`
217
- `sourceMaps` | Generate CSS source maps. | `true`
216
+ Name | Type | Desciption | Default value
217
+ --------------|---------|------------------------------------------------------------------|---------------
218
+ `recursive` | Boolean | Recursively search for nested files if dir path passed. | `true`
219
+ `verbose` | Boolean | Show logging in console/terminal. | `true`
220
+ `dotFolders` | Boolean | Include dotfolders in file search. | `false`
221
+ `minify` | Boolean | Minify output CSS. | `true`
222
+ `sourceMaps` | Boolean | Generate CSS source maps. | `true`
223
+ `ignoreFiles` | Array | Files (by name) to exclude from compilation. | `[]`
224
+ `comment` | String | Comment to prepend to compiled CSS. Separate by line using '\n'. | `''`
218
225
 
219
226
  #
220
227
 
@@ -243,11 +250,12 @@ findSCSS() » Check returned array.
243
250
 
244
251
  Available parameters (and their default settings) are:
245
252
 
246
- Name | Desciption | Default value
247
- -------------|----------------------------------------------------------|---------------
248
- `recursive` | Recursively search for nested files in searchDir passed. | `true`
249
- `verbose` | Show logging in console/terminal. | `true`
250
- `dotFolders` | Include dotfolders in file search. | `false`
253
+ Name | Type | Desciption | Default value
254
+ --------------|---------|----------------------------------------------------------|---------------
255
+ `recursive` | Boolean | Recursively search for nested files in searchDir passed. | `true`
256
+ `verbose` | Boolean | Show logging in console/terminal. | `true`
257
+ `dotFolders` | Boolean | Include dotfolders in file search. | `false`
258
+ `ignoreFiles` | Array | Files (by name) to exclude from search results. | `[]`
251
259
 
252
260
  <br>
253
261
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adamlui/scss-to-css",
3
- "version": "1.8.5",
3
+ "version": "1.9.0",
4
4
  "description": "Recursively compile all SCSS files into minified CSS",
5
5
  "author": {
6
6
  "name": "Adam Lui",