Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Meta tweaks
  • Loading branch information
sindresorhus committed Dec 31, 2018
1 parent 517e226 commit 692d85a
Show file tree
Hide file tree
Showing 10 changed files with 83 additions and 83 deletions.
3 changes: 1 addition & 2 deletions .gitattributes
@@ -1,2 +1 @@
* text=auto
*.js text eol=lf
* text=auto eol=lf
1 change: 1 addition & 0 deletions .gitignore
@@ -1 +1,2 @@
node_modules
yarn.lock
1 change: 1 addition & 0 deletions .npmrc
@@ -0,0 +1 @@
package-lock=false
1 change: 0 additions & 1 deletion .travis.yml
@@ -1,7 +1,6 @@
os:
- linux
- windows
sudo: false
language: node_js
node_js:
- '10'
Expand Down
15 changes: 8 additions & 7 deletions index.js
Expand Up @@ -128,20 +128,21 @@ if (platform === 'linux') {

const figures = platform === 'win32' ? win : main;

const fn = str => {
const fn = string => {
if (figures === main) {
return str;
return string;
}

Object.keys(main).forEach(key => {
// TODO: Use `Object.entries` when targeting Node.js 8
for (const key of Object.keys(main)) {
if (main[key] === figures[key]) {
return;
continue;
}

str = str.replace(new RegExp(escapeStringRegexp(main[key]), 'g'), figures[key]);
});
string = string.replace(new RegExp(escapeStringRegexp(main[key]), 'g'), figures[key]);
}

return str;
return string;
};

module.exports = Object.assign(fn, figures);
20 changes: 4 additions & 16 deletions license
@@ -1,21 +1,9 @@
The MIT License (MIT)
MIT License

Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (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:
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:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19 changes: 15 additions & 4 deletions makefile.js
Expand Up @@ -13,14 +13,25 @@ const darwin = load('darwin');
const win32 = load('win32');

const jsonTable = [
['Name', 'Real OSes', 'Windows']
[
'Name',
'Real OSes',
'Windows'
]
];

Object.keys(darwin).forEach(key => {
// 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: ['', 'c', 'c']});
const figureTable = table(jsonTable, {
align: [
'',
'c',
'c'
]
});

let readme = fs.readFileSync('readme.md', 'utf8');
readme = readme.replace(/## Figures[^#]*/gm, `## Figures\n\n${figureTable}\n\n\n`);
Expand Down
84 changes: 42 additions & 42 deletions package.json
@@ -1,44 +1,44 @@
{
"name": "figures",
"version": "2.0.0",
"description": "Unicode symbols with Windows CMD fallbacks",
"license": "MIT",
"repository": "sindresorhus/figures",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"engines": {
"node": ">=6"
},
"scripts": {
"test": "xo && ava",
"make": "./makefile.js"
},
"files": [
"index.js"
],
"keywords": [
"unicode",
"cli",
"cmd",
"command-line",
"characters",
"char",
"symbol",
"symbols",
"figure",
"figures",
"fallback"
],
"dependencies": {
"escape-string-regexp": "^1.0.5"
},
"devDependencies": {
"ava": "*",
"import-fresh": "^2.0.0",
"markdown-table": "^1.0.0",
"xo": "*"
}
"name": "figures",
"version": "2.0.0",
"description": "Unicode symbols with Windows CMD fallbacks",
"license": "MIT",
"repository": "sindresorhus/figures",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"engines": {
"node": ">=6"
},
"scripts": {
"test": "xo && ava",
"make": "./makefile.js"
},
"files": [
"index.js"
],
"keywords": [
"unicode",
"cli",
"cmd",
"command-line",
"characters",
"char",
"symbol",
"symbols",
"figure",
"figures",
"fallback"
],
"dependencies": {
"escape-string-regexp": "^1.0.5"
},
"devDependencies": {
"ava": "^1.0.1",
"import-fresh": "^3.0.0",
"markdown-table": "^1.0.0",
"xo": "^0.23.0"
}
}
4 changes: 2 additions & 2 deletions readme.md
Expand Up @@ -12,7 +12,7 @@ Windows CMD only supports a [limited character set](http://en.wikipedia.org/wiki
## Install

```
$ npm install --save figures
$ npm install figures
```


Expand All @@ -37,7 +37,7 @@ console.log(figures.tick);

### figures(input)

Returns the input with replaced fallback unicode symbols on Windows.
Returns the input with replaced fallback Unicode symbols on Windows.

All the below [figures](#figures) are attached to the main export as shown in the example above.

Expand Down
18 changes: 9 additions & 9 deletions test.js
@@ -1,18 +1,18 @@
import test from 'ava';
import m from '.';
import figures from '.';

const result = (main, win) => process.platform === 'win32' ? win : main;
const result = (main, windows) => process.platform === 'win32' ? windows : main;

console.log(' ' + Object.keys(m).map(x => m[x]).join(' ') + '\n');
console.log(' ' + Object.keys(figures).map(symbol => figures[symbol]).join(' ') + '\n');

test('figures', t => {
t.is(m.tick, result('✔', '√'));
t.is(figures.tick, result('✔', '√'));
});

test('fallbacks', t => {
t.is(m('foo'), 'foo');
t.is(m('?bar?'), '?bar?');
t.is(m('✔ ✔ ✔'), result('✔ ✔ ✔', '√ √ √'));
t.is(m('✔ ✖\n★ ▇'), result('✔ ✖\n★ ▇', '√ ×\n* █'));
t.is(m('✔ ✖ ★ ▇'), result('✔ ✖ ★ ▇', '√ × * █'));
t.is(figures('foo'), 'foo');
t.is(figures('?bar?'), '?bar?');
t.is(figures('✔ ✔ ✔'), result('✔ ✔ ✔', '√ √ √'));
t.is(figures('✔ ✖\n★ ▇'), result('✔ ✖\n★ ▇', '√ ×\n* █'));
t.is(figures('✔ ✖ ★ ▇'), result('✔ ✖ ★ ▇', '√ × * █'));
});

0 comments on commit 692d85a

Please sign in to comment.