@nsis/dent-cli 0.3.0 → 0.3.1
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/bin/cli.mjs +5 -5
- package/package.json +4 -2
package/bin/cli.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{promises as e}from"node:fs";import{dirname as
|
|
3
|
-
CLI parameters:`,{args:
|
|
4
|
-
Completed`),await Promise.all(
|
|
5
|
-
Conversion:`,{raw:n,formatted:
|
|
6
|
-
Completed`)}async function
|
|
2
|
+
import{promises as e}from"node:fs";import{platform as t}from"node:os";import{dirname as n,resolve as r}from"node:path";import{fileURLToPath as i}from"node:url";import{createFormatter as a}from"@nsis/dent";import{Command as o}from"commander";import{glob as s}from"glob";import c from"log-symbols";import l from"picocolors";await u();async function u(){let n=new o,r=await d();n.version(r).description(`CLI tool to format NSIS scripts`).arguments(`<file...>`).option(`--eol <"crlf"|"lf">`,`control how line-breaks are represented`,e=>{if(![`crlf`,`lf`].includes(e)){let e=t()===`win32`?`crlf`:`lf`;return console.log(`${c.warning} Invalid EOL value provided, defaulting to "${e}".`),e}return e}).option(`-i, --indent-size <number>`,`number of units per indentation level`,e=>Number.parseInt(e,10),2).option(`-s, --use-spaces`,`indent with spaces instead of tabs`,!1).option(`--trim`,`trim empty lines`,!0).option(`--write`,`edit files in-place`,!1).option(`--quiet`,`suppress output`,!1).option(`--debug`,`prints additional debug messages`,!1).parse(process.argv);let i=n.opts(),u=Array.isArray(n.args)?n.args:[n.args];u.length||n.help(),i.debug&&console.log(`
|
|
3
|
+
CLI parameters:`,{args:u,options:i});let f=a({endOfLines:i.eol,indentSize:i.indentSize,trimEmptyLines:i.trim,useTabs:!i.useSpaces}),p=await s(u),m=i.write&&!i.quiet;m&&!i.debug&&console.log(),console.time(`
|
|
4
|
+
Completed`),await Promise.all(p.map(async t=>{if(!t.endsWith(`.nsi`)&&!t.endsWith(`.nsh`)){console.warn(`${c.warning} ${l.blue(t)} is not an NSIS script, skipping.`);return}m&&console.time(`${c.success} ${l.blue(t)}`);let n=(await e.readFile(t)).toString(),r=f(n);if(i.debug&&console.log(`
|
|
5
|
+
Conversion:`,{raw:n,formatted:r}),i.write)try{await e.writeFile(t,r,{encoding:`utf-8`}),m&&console.timeEnd(`${c.success} ${l.blue(t)}`)}catch(e){m&&console.error(`${c.error} ${l.blue(t)} ${e instanceof Error?e.message:String(e)}`)}else console.log(r)})),m&&console.timeEnd(`
|
|
6
|
+
Completed`)}async function d(){let t=n(i(import.meta.url)),{version:a}=JSON.parse(await e.readFile(r(t,`../package.json`),`utf8`));return a||`dev`}export{};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nsis/dent-cli",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "An opinionated code formatter for NSIS scripts",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
@@ -31,8 +31,10 @@
|
|
|
31
31
|
"picocolors": "^1.0.0"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
+
"@commitlint/cli": "^20.4.1",
|
|
35
|
+
"@commitlint/config-conventional": "^20.4.1",
|
|
34
36
|
"@idleberg/configs": "^0.4.2",
|
|
35
|
-
"@types/node": "^
|
|
37
|
+
"@types/node": "^24.11.0",
|
|
36
38
|
"concurrently": "^9.2.1",
|
|
37
39
|
"np": "^11.0.2",
|
|
38
40
|
"tsdown": "^0.20.3",
|