Skip to content

Commit 7b3ef96

Browse files
committed
💥 ➖ ➕ Better colors
1 parent d3efa30 commit 7b3ef96

6 files changed

Lines changed: 31 additions & 33 deletions

File tree

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ s.mkdir(join(s.tempdir(), name));
2727
1. `npm install https://github.com/jaandrle/nodejsscript --global`
2828

2929
## Goods
30-
[s (shelljs)](#shelljs) · [cli()](#cli) · [chalk](#chalk-package) · [fetch()](#fetch) · [pipe()](#pipe) · [question()](#question) · [echo()](#echo) · [stdin()](#stdin) · [config](#config)
30+
[s (shelljs)](#shelljs) · [cli()](#cli) · [ansi-colors](#ansi-colors-package) · [fetch()](#fetch) · [pipe()](#pipe) · [question()](#question) · [echo()](#echo) · [stdin()](#stdin) · [config](#config)
3131

3232

3333
## Documentation
@@ -97,11 +97,10 @@ Function similar to [Ramda `R.pipe`](https://ramdajs.com/docs/#pipe)). Provides
9797
```js
9898
pipe(
9999
Number,
100-
v=> chalk.greenBright(v+1),
100+
v=> style.greenBright(v+1),
101101
v=> `Result is: ${v}`,
102102
echo
103103
)(await question("Choose number:"));
104-
105104
```
106105

107106
### `cli()`
@@ -162,11 +161,12 @@ const config.assign({ verbose: true, silent: false });
162161

163162
```
164163

165-
### `chalk` package
166-
The [chalk](https://www.npmjs.com/package/chalk) package.
164+
### `ansi-colors` package
165+
The [doowb/ansi-colors](https://github.com/doowb/ansi-colors) package as `style`.
167166

168167
```js
169-
echo(chalk.blue('Hello world!'));
168+
style.theme({ info: style.blue });
169+
echo(style.info('Hello world!'));
170170
```
171171

172172
[^node]: Alternatively `curl -sL install-node.vercel.app/17.0.1 | bash`

examples/pipes.mjs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
#!/usr/bin/env nodejsscript
22
/* jshint esversion: 8,-W097, -W040, node: true, expr: true, undef: true */
3-
import { s, pipe, echo, chalk, exit } from "nodejsscript";
3+
import { s, pipe, echo, style, exit } from "nodejsscript";
4+
style.theme({ pkg: style.magentaBright, version: style.greenBright });
45

56
s.$().exec("npm list")
67
.grep("─")
78
.grep("-v", "types")
89
.trim().split("\n")
910
.map(l=> l.slice(l.indexOf(" ")).split("@"))
1011
.forEach(pipe(
11-
([ pkg, version ])=> chalk.magentaBright(pkg)+"@"+chalk.greenBright(version),
12+
([ pkg, version ])=> style.pkg(pkg)+"@"+style.greenBright(version),
1213
echo
1314
));
1415

index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ export const config= {
4141
assign(...c){ return Object.assign(this, ...c); }
4242
};
4343

44-
import chalk from "chalk";
45-
export { chalk };
44+
import style from "ansi-colors";
45+
export { style };
4646

4747
import nodeFetch from 'node-fetch';
4848
/**
@@ -86,7 +86,7 @@ import { createInterface } from 'node:readline';
8686
* */
8787
export function question(query= "", options= undefined){
8888
query= String(query);
89-
if(!/\s$/.test(query)) query+= "\n"+chalk.greenBright.bold('❯ ');
89+
if(!/\s$/.test(query)) query+= "\n"+style.greenBright.bold('❯ ');
9090

9191
const rl= createInterface({
9292
input: process.stdin,

package-lock.json

Lines changed: 16 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nodejsscript",
3-
"version": "0.5.0",
3+
"version": "0.5.1",
44
"author": "Jan Andrle <andrle.jan@centrum.cz>",
55
"license": "MIT",
66
"description": "A tool for writing better scripts",
@@ -55,7 +55,7 @@
5555
"dependencies": {
5656
"@types/sade": "^1.7.4",
5757
"@types/shelljs": "^0.8.11",
58-
"chalk": "^5.0.1",
58+
"ansi-colors": "^4.1.3",
5959
"node-fetch": "^3.2.10",
6060
"sade": "^1.8.1",
6161
"shelljs": ">=v0.8.5"

types/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export * from './types/shelljs.d.ts';
22
export {
3-
chalk, fetch,
3+
style, fetch,
44
echo, question, stdin, cli
55
} from "./index.js";

0 commit comments

Comments
 (0)