@adamlui/scss-to-css 1.7.3 → 1.7.5
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 +11 -10
- package/dist/scss-to-css.min.js +13 -15
- package/package.json +9 -5
package/README.md
CHANGED
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
|
|
29
29
|
<a href="https://www.npmjs.com/package/@adamlui/scss-to-css"><img height=31 src="https://img.shields.io/npm/dt/%40adamlui%2Fscss-to-css?logo=npm&color=af68ff&logoColor=white&labelColor=464646&style=for-the-badge"></a>
|
|
30
30
|
<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>
|
|
31
|
-
<a href="https://github.com/adamlui/js-utils/releases/tag/scss-to-css-1.7.
|
|
31
|
+
<a href="https://github.com/adamlui/js-utils/releases/tag/scss-to-css-1.7.5"><img height=31 src="https://img.shields.io/badge/Latest_Build-1.7.5-44cc11.svg?logo=icinga&logoColor=white&labelColor=464646&style=for-the-badge"></a>
|
|
32
32
|
<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>
|
|
33
33
|
<a href="https://sonarcloud.io/component_measures?metric=new_vulnerabilities&id=adamlui_js-utils:scss-to-css/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_js-utils%3Ascss-to-css%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>
|
|
34
34
|
|
|
@@ -224,22 +224,23 @@ console.log(searchResults);
|
|
|
224
224
|
|
|
225
225
|
/* sample output:
|
|
226
226
|
|
|
227
|
-
Searching for SCSS files...
|
|
228
|
-
Search complete
|
|
227
|
+
findSCSS() » Searching for SCSS files...
|
|
228
|
+
findSCSS() » Search complete! 2 files found.
|
|
229
|
+
findSCSS() » Check returned array.
|
|
229
230
|
[
|
|
230
|
-
'E:\\js\\utils\\
|
|
231
|
-
'E:\\js\\utils\\
|
|
231
|
+
'E:\\js\\utils\\scss-to-css\assets\\scss\\foo.scss',
|
|
232
|
+
'E:\\js\\utils\\scss-to-css\assets\\scss\\bar.scss'
|
|
232
233
|
]
|
|
233
234
|
*/
|
|
234
235
|
```
|
|
235
236
|
|
|
236
237
|
Available parameters (and their default settings) are:
|
|
237
238
|
|
|
238
|
-
Name | Desciption
|
|
239
|
-
|
|
240
|
-
`recursive` | Recursively search for nested files
|
|
241
|
-
`verbose` | Show logging in console/terminal.
|
|
242
|
-
`dotFolders` | Include dotfolders in file search.
|
|
239
|
+
Name | Desciption | Default value
|
|
240
|
+
-------------|----------------------------------------------------------|---------------
|
|
241
|
+
`recursive` | Recursively search for nested files in searchDir passed. | `true`
|
|
242
|
+
`verbose` | Show logging in console/terminal. | `true`
|
|
243
|
+
`dotFolders` | Include dotfolders in file search. | `false`
|
|
243
244
|
|
|
244
245
|
<br>
|
|
245
246
|
|
package/dist/scss-to-css.min.js
CHANGED
|
@@ -1,25 +1,23 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
const c=require("fs"),l=require("path"),t=require("sass");function a(s,r={}){var e={recursive:!0,verbose:!0,dotFolders:!1};if(r={...e,...r}
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
findSCSS() » '${e}' does not exist.`);for(const n of Object.keys(s)){if(!Object.prototype.hasOwnProperty.call(o,n))return console.error(`compile() » ERROR: \`${n}\` is an invalid option.`+`
|
|
6
|
-
findSCSS() » Valid options: [ ${Object.keys(o).join(", ")} ]`);if("boolean"!=typeof s[n])return console.error(`compile() » ERROR: \`${n}\` option must be set to \`true\` or \`false\`.`)}const r={style:s.minify?"compressed":"expanded",sourceMap:s.sourceMaps};if(c.existsSync(e)){if(!e.endsWith(".scss"))return a(e,{recursive:s.recursive,verbose:s.verbose,dotFolders:s.dotFolders})?.map(e=>{s.verbose&&console.info(`compile() » Compiling ${e}...`);try{var o=t.compile(e,r);return console.info("compile() » Compilation complete! Check returned object."),{code:o.css,srcMap:o.sourceMap,srcPath:e}}catch(e){return console.error(`
|
|
2
|
+
const c=require("fs"),l=require("path"),t=require("sass");function a(s,r={}){var e={recursive:!0,verbose:!0,dotFolders:!1};if(r={...e,...r},"string"!=typeof s)return console.error("findSCSS() » ERROR: 1st arg <searchDir> must be a string.");var o=l.resolve(process.cwd(),s);if(!c.existsSync(o))return console.error("findSCSS() » ERROR: 1st arg <searchDir> must be an existing directory.\n"+`findSCSS() » ${o} does not exist.`);for(const t of Object.keys(r))if(!Object.prototype.hasOwnProperty.call(e,t)){if("isRecursing"!==t)return console.error(`findSCSS() » ERROR: \`${t}\` is an invalid option.
|
|
3
|
+
`+`findSCSS() » Valid options: [ ${Object.keys(e).join(", ")} ]`);if("boolean"!=typeof r[t])return console.error(`findSCSS() » ERROR: \`${t}\` option can only be set to \`true\` or \`false\`.`)}const i=c.readdirSync(s),n=[];return r.verbose&&!r.isRecursing&&console.info("\nfindSCSS() » Searching for SCSS files..."),i.forEach(e=>{var o=l.resolve(s,e);c.statSync(o).isDirectory()&&"node_modules"!=e&&(r.dotFolders||!e.startsWith("."))&&r.recursive?n.push(...a(o,{...r,isRecursing:!0})):e.endsWith(".scss")&&n.push(o)}),!r.isRecursing&&r.verbose&&console.info("findSCSS() » Search complete! "+(0===n.length?"No":n.length)+` file${1<n.length?"s":""} found.`+("compile"!==a.caller.name&&require.main!==module?"\nfindSCSS() » Check returned array.":"")),r.isRecursing||0<n.length?n:[]}function s(e,s={}){var o={minify:!0,sourceMaps:!0,recursive:!0,verbose:!0,dotFolders:!1};if(s={...o,...s},"string"!=typeof e)return console.error("findSCSS() » ERROR: 1st arg <inputPath> must be a string.");if(e=l.resolve(process.cwd(),e),!c.existsSync(e))return console.error("findSCSS() » ERROR: 1st arg <inputPath> must be an existing directory or file.\n"+`findSCSS() » ${e} does not exist.`);for(const n of Object.keys(s)){if(!Object.prototype.hasOwnProperty.call(o,n))return console.error(`compile() » ERROR: \`${n}\` is an invalid option.
|
|
4
|
+
`+`compile() » Valid options: [ ${Object.keys(o).join(", ")} ]`);if("boolean"!=typeof s[n])return console.error(`compile() » ERROR: \`${n}\` option can only be set to \`true\` or \`false\`.`)}const r={style:s.minify?"compressed":"expanded",sourceMap:s.sourceMaps};if(c.existsSync(e)){if(!e.endsWith(".scss"))return a(e,{recursive:s.recursive,verbose:s.verbose,dotFolders:s.dotFolders})?.map(e=>{s.verbose&&console.info(`compile() » Compiling ${e}...`);try{var o=t.compile(e,r);return{code:o.css,srcMap:o.sourceMap,srcPath:e}}catch(e){return console.error(`
|
|
7
5
|
compile() » ERROR: ${e.message}
|
|
8
|
-
`),{error:e}}}).filter(e=>!e.error);s.verbose&&console.info(`compile() » Compiling ${e}...`);try{var i=t.compile(e,r);return
|
|
6
|
+
`),{error:e}}}).filter(e=>!e.error);s.verbose&&console.info(`compile() » Compiling ${e}...`);try{var i=t.compile(e,r);return{code:i.css,srcMap:i.sourceMap,srcPath:l.resolve(process.cwd(),e)}}catch(e){return console.error(`
|
|
9
7
|
compile() » ERROR: ${e.message}
|
|
10
|
-
`),{error:e}}}}if(require.main!==module)module.exports={compile:s,findSCSS:a};else{const i="[0m",n="[1;91m",
|
|
8
|
+
`),{error:e}}}}if(require.main!==module)module.exports={compile:s,findSCSS:a};else{const i="[0m",n="[1;91m",d="[1;33m",e="[1;92m",f={},u={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(o=>{var e;o.startsWith("-")&&((e=Object.keys(u).find(e=>u[e].test(o)))?f[e]=!0:(console.error(`
|
|
11
9
|
${n}ERROR: Arg [${o}] not recognized.`+i),console.info(`
|
|
12
|
-
${
|
|
13
|
-
${n}Error: First argument
|
|
10
|
+
${d}Valid arguments are below.`+i),r(["configOptions","infoCmds"]),process.exit(1)))}),process.argv.some(e=>u.help.test(e)))r();else if(process.argv.some(e=>u.version.test(e)))console.info("v"+require("./package.json").version);else{const[p="",m=""]=process.argv.slice(2).filter(e=>!e.startsWith("-")).map(e=>e.replace(/^\/*/,"")),S=l.resolve(process.cwd(),p),h=(p&&!c.existsSync(S)&&(console.error(`
|
|
11
|
+
${n}Error: First argument can only be an existing file or directory.`+`
|
|
14
12
|
'${S}' does not exist.`+i+`
|
|
15
13
|
|
|
16
14
|
${e}Example valid command:
|
|
17
15
|
>> scss-to-css . output.min.css`+i+`
|
|
18
16
|
|
|
19
|
-
${
|
|
20
|
-
>> scss-to-css --help`+i),process.exit(1)),
|
|
21
|
-
${
|
|
22
|
-
No SCSS files will be compiled.`+i);else{const g=[],v=h.map(e=>{var o=s(e,{minify:!
|
|
23
|
-
${e}Compilation complete!`+i),o(v.length+" CSS file"+y+(
|
|
17
|
+
${d}For all command options:
|
|
18
|
+
>> scss-to-css --help`+i),process.exit(1)),p.endsWith(".scss")?[S]:a(S,{recursive:!f.noRecursion,verbose:!f.quietMode}));if(f.dryRun)0<h.length?(console.info(`
|
|
19
|
+
${d}SCSS files to be compiled:`+i),h.forEach(e=>console.info(e))):console.info(d+`
|
|
20
|
+
No SCSS files will be compiled.`+i);else{const g=[],v=h.map(e=>{var o=s(e,{minify:!f.noMinify,sourceMaps:!f.noSourceMaps,verbose:!f.quietMode});return o.error&&g.push(e),o}).filter(e=>!e.error);if(v?.forEach(({code:e,srcMap:o,srcPath:s})=>{var r=l.join(l.dirname(s),/(?:src|s[ac]ss)$/.test(l.dirname(s))?"../css":m.endsWith(".css")?l.dirname(m):m||"css"),s=(m.endsWith(".css")&&p.endsWith(".scss")?l.basename(m).replace(/(\.min)?\.css$/,""):l.basename(s,".scss"))+".min.css",s=l.join(r,s);c.existsSync(r)||c.mkdirSync(r,{recursive:!0}),c.writeFileSync(s,e,"utf8"),f.noSourceMaps||c.writeFileSync(s+".map",JSON.stringify(o),"utf8")}),0<v?.length){const y=1<v.length?"s":"";o(`
|
|
21
|
+
${e}Compilation complete!`+i),o(v.length+" CSS file"+y+(f.noSourceMaps?"":` + ${v.length} source map`+y)+" generated.")}else o(d+"No SCSS files processed."+i);0<g.length&&(o(`
|
|
24
22
|
`+n+g.length+" file"+(1<g.length?"s":"")+" failed to compile:"+i),g.forEach(e=>o(e)))}}function r(e=["cmdFormat","pathArgs","configOptions","infoCmds"]){const o={cmdFormat:[`
|
|
25
|
-
${
|
|
23
|
+
${d}scss-to-css [inputPath] [outputPath] [options]`+i],pathArgs:["\nPath arguments:"," [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:["\nConfig options:"," -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:["\nInfo commands:"," -h, --help Display help screen."," -v, --version Show version number."]};e.forEach(e=>{o[e]?.forEach(e=>{{const r=process.stdout.columns||80,i=[],o=e.match(/\S+|\s+/g);let s="";o.forEach(e=>{var o=r-(0===i.length?0:30);s.length+e.length>o&&(i.push(0===i.length?s:s.trimStart()),s=""),s+=e}),i.push(0===i.length?s:s.trimStart()),i.forEach((e,o)=>console.info(0===o?e:" ".repeat(30)+e))}})})}function o(e){f.quietMode||console.info(e)}}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adamlui/scss-to-css",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.5",
|
|
4
4
|
"description": "Recursively compile all SCSS files into minified CSS",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Adam Lui",
|
|
@@ -16,12 +16,16 @@
|
|
|
16
16
|
"!docs/*/"
|
|
17
17
|
],
|
|
18
18
|
"bin": {
|
|
19
|
-
"scsstocss": "dist/
|
|
20
|
-
"scss-to-css": "dist/
|
|
19
|
+
"scsstocss": "dist/cli.min.js",
|
|
20
|
+
"scss-to-css": "dist/cli.min.js"
|
|
21
|
+
},
|
|
22
|
+
"directories": {
|
|
23
|
+
"lib": ".",
|
|
24
|
+
"doc": "./docs"
|
|
21
25
|
},
|
|
22
26
|
"scripts": {
|
|
23
27
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
24
|
-
"build": "minify-js
|
|
28
|
+
"build": "minify-js src dist",
|
|
25
29
|
"bump:patch": "bash utils/bump.sh patch",
|
|
26
30
|
"bump:minor": "bash utils/bump.sh minor",
|
|
27
31
|
"bump:major": "bash utils/bump.sh major",
|
|
@@ -54,6 +58,6 @@
|
|
|
54
58
|
"url": "https://github.com/sponsors/adamlui"
|
|
55
59
|
},
|
|
56
60
|
"devDependencies": {
|
|
57
|
-
"@adamlui/minify.js": "^1.4.
|
|
61
|
+
"@adamlui/minify.js": "^1.4.8"
|
|
58
62
|
}
|
|
59
63
|
}
|