From e9c4d9de733ef9651172712608cf7afe8ab3f066 Mon Sep 17 00:00:00 2001 From: Jan Andrle Date: Tue, 21 Feb 2023 09:36:15 +0100 Subject: [PATCH] v0.9.2 (#24) --- README.md | 8 +- _index.d.ts | 2 +- bin/cli.mjs | 44 +- docs/README.md | 32 +- docs/classes/fetch.Response.md | 20 +- docs/classes/s.ProcessPromise.md | 32 +- docs/classes/s.child.ChildProcess.md | 12 +- docs/interfaces/EchoFunction.md | 153 +++- docs/interfaces/s.CatFunction.md | 2 +- docs/interfaces/s.ChmodFunction.md | 2 +- docs/interfaces/s.CopyFunction.md | 2 +- docs/interfaces/s.DirsFunction.md | 6 +- docs/interfaces/s.DollarFunction.md | 2 +- docs/interfaces/s.EchoFunction.md | 6 +- docs/interfaces/s.ExecOptions.md | 2 +- docs/interfaces/s.FindFunction.md | 2 +- docs/interfaces/s.GrepFunction.md | 6 +- docs/interfaces/s.HeadFunction.md | 4 +- docs/interfaces/s.LinkFunction.md | 2 +- docs/interfaces/s.ListFunction.md | 6 +- docs/interfaces/s.MkdirFunction.md | 6 +- docs/interfaces/s.MoveFunction.md | 2 +- docs/interfaces/s.PopDirFunction.md | 6 +- docs/interfaces/s.PushDirFunction.md | 18 +- docs/interfaces/s.RemoveFunction.md | 6 +- docs/interfaces/s.SedFunction.md | 6 +- docs/interfaces/s.SortFunction.md | 6 +- docs/interfaces/s.TailFunction.md | 4 +- docs/interfaces/s.TouchFunction.md | 4 +- docs/interfaces/s.UniqFunction.md | 2 +- docs/interfaces/s.XargsFunction.md | 4 +- .../interfaces/s.child.ChildProcessByStdio.md | 2 +- .../s.child.ChildProcessWithoutNullStreams.md | 2 +- docs/interfaces/s.child.CommonExecOptions.md | 2 +- docs/interfaces/s.child.CommonOptions.md | 2 +- docs/interfaces/s.child.CommonSpawnOptions.md | 2 +- docs/interfaces/s.child.ExecFileOptions.md | 2 +- ...child.ExecFileOptionsWithBufferEncoding.md | 2 +- ....child.ExecFileOptionsWithOtherEncoding.md | 2 +- ...child.ExecFileOptionsWithStringEncoding.md | 2 +- .../interfaces/s.child.ExecFileSyncOptions.md | 2 +- ...d.ExecFileSyncOptionsWithBufferEncoding.md | 2 +- ...d.ExecFileSyncOptionsWithStringEncoding.md | 2 +- docs/interfaces/s.child.ExecOptions.md | 2 +- .../s.child.ExecOptionsWithBufferEncoding.md | 2 +- .../s.child.ExecOptionsWithStringEncoding.md | 2 +- docs/interfaces/s.child.ExecSyncOptions.md | 2 +- ...child.ExecSyncOptionsWithBufferEncoding.md | 2 +- ...child.ExecSyncOptionsWithStringEncoding.md | 2 +- docs/interfaces/s.child.SpawnOptions.md | 2 +- .../s.child.SpawnOptionsWithStdioTuple.md | 2 +- .../s.child.SpawnOptionsWithoutStdio.md | 2 +- docs/interfaces/s.child.SpawnSyncOptions.md | 2 +- ...hild.SpawnSyncOptionsWithBufferEncoding.md | 2 +- ...hild.SpawnSyncOptionsWithStringEncoding.md | 2 +- docs/interfaces/sade.Sade.md | 2 +- docs/modules/.md | 10 +- docs/modules/_sade.md | 2 +- docs/modules/s.md | 118 +-- docs/modules/xdg_.md | 4 +- docs/modules/xdg_.xdg.md | 95 +- examples/abort_signal.mjs | 11 + examples/echo.mjs | 25 +- examples/xdg.mjs | 11 +- package-lock.json | 839 ++---------------- package.json | 18 +- src/$.js | 22 +- src/Error.js | 5 +- src/ansi_constants.js | 50 -- src/echo.d.ts | 36 +- src/echo.js | 77 +- src/runA-utils.js | 17 +- src/shelljs.js | 17 +- src/xdg.d.ts | 5 +- src/xdg.js | 13 +- 75 files changed, 623 insertions(+), 1211 deletions(-) create mode 100755 examples/abort_signal.mjs delete mode 100644 src/ansi_constants.js diff --git a/README.md b/README.md index 25a55d5..c5bc224 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ curl https://api.spacexdata.com/v4/launches/latest | nodejsscript -p 'Object.ent ## Goods [s #shelljs](./docs/modules/s.md) · [$](./docs/modules/.md) ([$.api() #sade](./docs/modules/.md#api), [$.read()](./docs/modules/.md#read), [$.xdg](./docs/modules/xdg_.xdg.md), …) - · [echo()](./docs/README.md#echo) + · [echo() #css-in-console](./docs/README.md#echo) · [fetch() #node-fetch](./docs/README.md#fetch) · [pipe()](./docs/README.md#pipe) · [cyclicLoop()](./docs/README.md#cyclicloop) @@ -136,6 +136,12 @@ Keep in mind that you can always turn off this for next command by using: s.$("-g").rm("*.txt"); ``` +## Helper(s) for developing +You can create `jsconfig.json` to help your editor provide proper suggestions. +As editor you can use VSCode or Vim with for example [neoclide/coc.nvim](https://github.com/neoclide/coc.nvim). +NodeJSScript provides `nodejsscript --global-jsconfig add script_file` to +help generate `jsconfig.json`. + ## Migration from `zx` The `runA` is almost identical to `$`: ```js diff --git a/_index.d.ts b/_index.d.ts index 15187cf..c07e826 100644 --- a/_index.d.ts +++ b/_index.d.ts @@ -1,5 +1,5 @@ /** @category Public */ -export { echo, EchoFunction, css_rules, css_colors } from './src/echo.d'; +export { echo, EchoFunction } from './src/echo.d'; export { xdg_, __sade, _env, _exit } from './src/$.d'; /** * Contains configuration for current script and methods diff --git a/bin/cli.mjs b/bin/cli.mjs index 0dd9600..5e07c2b 100755 --- a/bin/cli.mjs +++ b/bin/cli.mjs @@ -8,7 +8,7 @@ import { stdin as key_stdin } from "../src/keys.js"; process.on('uncaughtException', printError); (async function main(){ - const candidate= argv.splice(2, 1)[0]; + const candidate= argv.splice(2, 1)[0] || "--help"; let filepath_tmp; if(candidate[0]==="-") filepath_tmp= handleMyArgvs(candidate); @@ -58,15 +58,15 @@ function printError(e){ } function printUsage(){ const [ n, v, d ]= info("name", "version", "description"); - const css= echo.css( - "* { margin-left: 2; }", - ".n { color: lightblue; }", - ".v { color: lightgreen; margin-left: 0; }", - ".code { font-style: italic; margin-left: 0; }", - ".H { color: yellow; }", - ".T { margin-left: 4; }" - ); - echo(`%c${n}@%c${v}`, css.n, css.v); + const css= echo.css` + * { margin-left: 2; } + .n { color: lightblue; } + .v { color: lightgreen; margin-left: 0; } + .code { font-style: italic; margin-left: 0; } + .H { color: yellow; } + .T { margin-left: 4; } + `; + echo("%c%s%c@%c%s", css.n, css.unset, css.v, n, v); echo(`%c${d}`, css.T); echo(`%cUsage%c:`, css.H); echo(`%c${n} [options]