From 293a4e5b638a6f2df9538c036262f9955d5f6002 Mon Sep 17 00:00:00 2001 From: Richie Bendall Date: Thu, 16 Jan 2020 17:41:44 +1300 Subject: [PATCH 1/4] Use newer syntax in the makefile (#33) Co-authored-by: Sindre Sorhus --- makefile.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/makefile.js b/makefile.js index 0dae68c..b21f800 100755 --- a/makefile.js +++ b/makefile.js @@ -12,19 +12,17 @@ const load = value => { const darwin = load('darwin'); const win32 = load('win32'); +const data = Object.entries(darwin).map(([name, figure]) => [name, figure, win32[name]]); + const jsonTable = [ [ 'Name', 'Real OSes', 'Windows' - ] + ], + ...data ]; -// TODO: Use `Object.entries` when targeting Node.js 8 -for (const key of Object.keys(darwin)) { - jsonTable.push([key, darwin[key], win32[key]]); -} - const figureTable = table(jsonTable, { align: [ '', From f1ad9fe42ebf1a21269f233591ec316dbbe126d3 Mon Sep 17 00:00:00 2001 From: Richie Bendall Date: Mon, 17 Feb 2020 03:45:37 +1300 Subject: [PATCH 2/4] Export platform-specific symbol sets (#32) --- index.d.ts | 56 +++++++++++++++++++++++++++++++--------------------- index.js | 2 ++ makefile.js | 10 +--------- package.json | 1 - readme.md | 16 +++++++++++++++ test.js | 5 +++++ 6 files changed, 57 insertions(+), 33 deletions(-) diff --git a/index.d.ts b/index.d.ts index c00c8e6..d477527 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,25 +1,4 @@ -declare const figures: { - /** - Replace unicode symbols depending on the OS. - - @param string - String where the Unicode symbols will be replaced with fallback symbols depending on the OS. - @returns The input with replaced fallback Unicode symbols on Windows. - - @example - ``` - import figures = require('figures'); - - console.log(figures('✔︎ check')); - // On real OSes: ✔︎ check - // On Windows: √ check - - console.log(figures.tick); - // On real OSes: ✔︎ - // On Windows: √ - ``` - */ - (string: string): string; - +declare const figureSet: { readonly tick: string; readonly cross: string; readonly star: string; @@ -77,6 +56,37 @@ declare const figures: { readonly fiveSixths: string; readonly fiveEighths: string; readonly sevenEighth: string; -}; +} + +type FigureSet = typeof figureSet + +declare const figures: { + /** + Replace unicode symbols depending on the OS. + + @param string - String where the Unicode symbols will be replaced with fallback symbols depending on the OS. + @returns The input with replaced fallback Unicode symbols on Windows. + + @example + ``` + import figures = require('figures'); + + console.log(figures('✔︎ check')); + // On real OSes: ✔︎ check + // On Windows: √ check + + console.log(figures.tick); + // On real OSes: ✔︎ + // On Windows: √ + ``` + */ + (string: string): string; + + /** Figures to use when not running on Windows. */ + readonly main: FigureSet; + + /** Figures to use when running on Windows. */ + readonly windows: FigureSet; +} & FigureSet; export = figures; diff --git a/index.js b/index.js index 10bd6ed..6288dc1 100644 --- a/index.js +++ b/index.js @@ -147,3 +147,5 @@ const fn = string => { }; module.exports = Object.assign(fn, figures); +module.exports.main = main; +module.exports.windows = windows; diff --git a/makefile.js b/makefile.js index b21f800..a513d06 100755 --- a/makefile.js +++ b/makefile.js @@ -1,16 +1,8 @@ #!/usr/bin/env node 'use strict'; const fs = require('fs'); -const importFresh = require('import-fresh'); const table = require('markdown-table'); - -const load = value => { - Object.defineProperty(process, 'platform', {value}); - return importFresh('.'); -}; - -const darwin = load('darwin'); -const win32 = load('win32'); +const {main: darwin, windows: win32} = require('.'); const data = Object.entries(darwin).map(([name, figure]) => [name, figure, win32[name]]); diff --git a/package.json b/package.json index aea2cf2..3e7c2c1 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,6 @@ }, "devDependencies": { "ava": "^1.4.1", - "import-fresh": "^3.0.0", "markdown-table": "^1.1.2", "tsd": "^0.7.2", "xo": "^0.24.0" diff --git a/readme.md b/readme.md index cf53700..1412264 100644 --- a/readme.md +++ b/readme.md @@ -30,6 +30,12 @@ console.log(figures('✔︎ check')); console.log(figures.tick); // On real OSes: ✔︎ // On Windows: √ + +console.log(figures.main.tick); +// On all OSes: ✔︎ + +console.log(figures.windows.tick); +// On all OSes: √ ``` @@ -48,6 +54,16 @@ Type: `string` String where the Unicode symbols will be replaced with fallback symbols depending on the OS. +### figures.main + +Figures to use when not running on Windows. + + +### figures.windows + +Figures to use when running on Windows. + + ## Figures | Name | Real OSes | Windows | diff --git a/test.js b/test.js index 2e3298f..77b4744 100644 --- a/test.js +++ b/test.js @@ -16,3 +16,8 @@ test('fallbacks', t => { t.is(figures('✔ ✖\n★ ▇'), result('✔ ✖\n★ ▇', '√ ×\n* █')); t.is(figures('✔ ✖ ★ ▇'), result('✔ ✖ ★ ▇', '√ × * █')); }); + +test('exported sets', t => { + t.is(figures.main.tick, '✔'); + t.is(figures.windows.tick, '√'); +}); From 3ae05eed1d13ae0d2e9eb6c6e598f454b12766bf Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Sun, 16 Feb 2020 21:52:59 +0700 Subject: [PATCH 3/4] Meta tweaks --- index.d.ts | 18 ++++--- index.js | 2 +- license | 2 +- makefile.js | 2 +- package.json | 3 +- readme.md | 136 ++++++++++++++++++++++++--------------------------- 6 files changed, 81 insertions(+), 82 deletions(-) diff --git a/index.d.ts b/index.d.ts index d477527..e770ef3 100644 --- a/index.d.ts +++ b/index.d.ts @@ -62,7 +62,7 @@ type FigureSet = typeof figureSet declare const figures: { /** - Replace unicode symbols depending on the OS. + Replace Unicode symbols depending on the OS. @param string - String where the Unicode symbols will be replaced with fallback symbols depending on the OS. @returns The input with replaced fallback Unicode symbols on Windows. @@ -72,20 +72,24 @@ declare const figures: { import figures = require('figures'); console.log(figures('✔︎ check')); - // On real OSes: ✔︎ check - // On Windows: √ check + // On non-Windows OSes: ✔︎ check + // On Windows: √ check console.log(figures.tick); - // On real OSes: ✔︎ - // On Windows: √ + // On non-Windows OSes: ✔︎ + // On Windows: √ ``` */ (string: string): string; - /** Figures to use when not running on Windows. */ + /** + Symbols to use when not running on Windows. + */ readonly main: FigureSet; - /** Figures to use when running on Windows. */ + /** + Symbols to use when running on Windows. + */ readonly windows: FigureSet; } & FigureSet; diff --git a/index.js b/index.js index 6288dc1..2cbe2db 100644 --- a/index.js +++ b/index.js @@ -124,7 +124,7 @@ const windows = { }; if (platform === 'linux') { - // The main one doesn't look that good on Ubuntu + // The main one doesn't look that good on Ubuntu. main.questionMarkPrefix = '?'; } diff --git a/license b/license index e7af2f7..fa7ceba 100644 --- a/license +++ b/license @@ -1,6 +1,6 @@ MIT License -Copyright (c) Sindre Sorhus (sindresorhus.com) +Copyright (c) Sindre Sorhus (https://sindresorhus.com) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: diff --git a/makefile.js b/makefile.js index a513d06..f6afc50 100755 --- a/makefile.js +++ b/makefile.js @@ -9,7 +9,7 @@ const data = Object.entries(darwin).map(([name, figure]) => [name, figure, win32 const jsonTable = [ [ 'Name', - 'Real OSes', + 'Non-Windows', 'Windows' ], ...data diff --git a/package.json b/package.json index 3e7c2c1..39cecef 100644 --- a/package.json +++ b/package.json @@ -4,10 +4,11 @@ "description": "Unicode symbols with Windows CMD fallbacks", "license": "MIT", "repository": "sindresorhus/figures", + "funding": "https://github.com/sponsors/sindresorhus", "author": { "name": "Sindre Sorhus", "email": "sindresorhus@gmail.com", - "url": "sindresorhus.com" + "url": "https://sindresorhus.com" }, "engines": { "node": ">=8" diff --git a/readme.md b/readme.md index 1412264..22d3620 100644 --- a/readme.md +++ b/readme.md @@ -8,14 +8,12 @@ Windows CMD only supports a [limited character set](http://en.wikipedia.org/wiki/Code_page_437). - ## Install ``` $ npm install figures ``` - ## Usage See the [source](index.js) for supported symbols. @@ -24,12 +22,12 @@ See the [source](index.js) for supported symbols. const figures = require('figures'); console.log(figures('✔︎ check')); -// On real OSes: ✔︎ check -// On Windows: √ check +// On non-Windows OSes: ✔︎ check +// On Windows: √ check console.log(figures.tick); -// On real OSes: ✔︎ -// On Windows: √ +// On non-Windows OSes: ✔︎ +// On Windows: √ console.log(figures.main.tick); // On all OSes: ✔︎ @@ -38,7 +36,6 @@ console.log(figures.windows.tick); // On all OSes: √ ``` - ## API ### figures(string) @@ -53,85 +50,82 @@ Type: `string` String where the Unicode symbols will be replaced with fallback symbols depending on the OS. - ### figures.main -Figures to use when not running on Windows. - +Symbols to use when not running on Windows. ### figures.windows -Figures to use when running on Windows. +Symbols to use when running on Windows. ## Figures -| Name | Real OSes | Windows | -| ------------------ | :-------: | :-----: | -| tick | ✔ | √ | -| cross | ✖ | × | -| star | ★ | * | -| square | ▇ | █ | -| squareSmall | ◻ | [ ] | -| squareSmallFilled | ◼ | [█] | -| play | ▶ | ► | -| circle | ◯ | ( ) | -| circleFilled | ◉ | (*) | -| circleDotted | ◌ | ( ) | -| circleDouble | ◎ | ( ) | -| circleCircle | ⓞ | (○) | -| circleCross | ⓧ | (×) | -| circlePipe | Ⓘ | (│) | -| circleQuestionMark | ?⃝ | (?) | -| bullet | ● | * | -| dot | ․ | . | -| line | ─ | ─ | -| ellipsis | … | ... | -| pointer | ❯ | > | -| pointerSmall | › | » | -| info | ℹ | i | -| warning | ⚠ | ‼ | -| hamburger | ☰ | ≡ | -| smiley | ㋡ | ☺ | -| mustache | ෴ | ┌─┐ | -| heart | ♥ | ♥ | -| nodejs | ⬢ | ♦ | -| arrowUp | ↑ | ↑ | -| arrowDown | ↓ | ↓ | -| arrowLeft | ← | ← | -| arrowRight | → | → | -| radioOn | ◉ | (*) | -| radioOff | ◯ | ( ) | -| checkboxOn | ☒ | [×] | -| checkboxOff | ☐ | [ ] | -| checkboxCircleOn | ⓧ | (×) | -| checkboxCircleOff | Ⓘ | ( ) | -| questionMarkPrefix | ?⃝ | ? | -| oneHalf | ½ | 1/2 | -| oneThird | ⅓ | 1/3 | -| oneQuarter | ¼ | 1/4 | -| oneFifth | ⅕ | 1/5 | -| oneSixth | ⅙ | 1/6 | -| oneSeventh | ⅐ | 1/7 | -| oneEighth | ⅛ | 1/8 | -| oneNinth | ⅑ | 1/9 | -| oneTenth | ⅒ | 1/10 | -| twoThirds | ⅔ | 2/3 | -| twoFifths | ⅖ | 2/5 | -| threeQuarters | ¾ | 3/4 | -| threeFifths | ⅗ | 3/5 | -| threeEighths | ⅜ | 3/8 | -| fourFifths | ⅘ | 4/5 | -| fiveSixths | ⅚ | 5/6 | -| fiveEighths | ⅝ | 5/8 | -| sevenEighths | ⅞ | 7/8 | +| Name | Non-Windows | Windows | +| ------------------ | :---------: | :-----: | +| tick | ✔ | √ | +| cross | ✖ | × | +| star | ★ | * | +| square | ▇ | █ | +| squareSmall | ◻ | [ ] | +| squareSmallFilled | ◼ | [█] | +| play | ▶ | ► | +| circle | ◯ | ( ) | +| circleFilled | ◉ | (*) | +| circleDotted | ◌ | ( ) | +| circleDouble | ◎ | ( ) | +| circleCircle | ⓞ | (○) | +| circleCross | ⓧ | (×) | +| circlePipe | Ⓘ | (│) | +| circleQuestionMark | ?⃝ | (?) | +| bullet | ● | * | +| dot | ․ | . | +| line | ─ | ─ | +| ellipsis | … | ... | +| pointer | ❯ | > | +| pointerSmall | › | » | +| info | ℹ | i | +| warning | ⚠ | ‼ | +| hamburger | ☰ | ≡ | +| smiley | ㋡ | ☺ | +| mustache | ෴ | ┌─┐ | +| heart | ♥ | ♥ | +| nodejs | ⬢ | ♦ | +| arrowUp | ↑ | ↑ | +| arrowDown | ↓ | ↓ | +| arrowLeft | ← | ← | +| arrowRight | → | → | +| radioOn | ◉ | (*) | +| radioOff | ◯ | ( ) | +| checkboxOn | ☒ | [×] | +| checkboxOff | ☐ | [ ] | +| checkboxCircleOn | ⓧ | (×) | +| checkboxCircleOff | Ⓘ | ( ) | +| questionMarkPrefix | ?⃝ | ? | +| oneHalf | ½ | 1/2 | +| oneThird | ⅓ | 1/3 | +| oneQuarter | ¼ | 1/4 | +| oneFifth | ⅕ | 1/5 | +| oneSixth | ⅙ | 1/6 | +| oneSeventh | ⅐ | 1/7 | +| oneEighth | ⅛ | 1/8 | +| oneNinth | ⅑ | 1/9 | +| oneTenth | ⅒ | 1/10 | +| twoThirds | ⅔ | 2/3 | +| twoFifths | ⅖ | 2/5 | +| threeQuarters | ¾ | 3/4 | +| threeFifths | ⅗ | 3/5 | +| threeEighths | ⅜ | 3/8 | +| fourFifths | ⅘ | 4/5 | +| fiveSixths | ⅚ | 5/6 | +| fiveEighths | ⅝ | 5/8 | +| sevenEighths | ⅞ | 7/8 | ## Related - [log-symbols](https://github.com/sindresorhus/log-symbols) - Colored symbols for various log levels - ---
From add96242a5467efdcca234433a21da6554df6410 Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Sun, 16 Feb 2020 21:55:03 +0700 Subject: [PATCH 4/4] 3.2.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 39cecef..ee3b3df 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "figures", - "version": "3.1.0", + "version": "3.2.0", "description": "Unicode symbols with Windows CMD fallbacks", "license": "MIT", "repository": "sindresorhus/figures",