Skip to content

Commit

Permalink
Require Node.js 12 and move to ESM
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Apr 18, 2021
1 parent b507bab commit 3721d57
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 26 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/main.yml
Expand Up @@ -12,10 +12,9 @@ jobs:
node-version:
- 14
- 12
- 10
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- run: npm install
Expand Down
6 changes: 3 additions & 3 deletions browser.js
@@ -1,8 +1,8 @@
'use strict';

module.exports = {
const logSymbols = {
info: 'ℹ️',
success: '✅',
warning: '⚠️',
error: '❌️'
};

export default logSymbols;
7 changes: 2 additions & 5 deletions index.d.ts
Expand Up @@ -5,7 +5,7 @@ Includes fallbacks for Windows CMD which only supports a [limited character set]
@example
```
import logSymbols = require('log-symbols');
import logSymbols from 'log-symbols';
console.log(logSymbols.success, 'Finished successfully!');
// Terminals with Unicode support: ✔ Finished successfully!
Expand All @@ -14,12 +14,9 @@ console.log(logSymbols.success, 'Finished successfully!');
*/
declare const logSymbols: {
readonly info: string;

readonly success: string;

readonly warning: string;

readonly error: string;
};

export = logSymbols;
export default logSymbols;
9 changes: 5 additions & 4 deletions index.js
@@ -1,6 +1,5 @@
'use strict';
const chalk = require('chalk');
const isUnicodeSupported = require('is-unicode-supported');
import chalk from 'chalk';
import isUnicodeSupported from 'is-unicode-supported';

const main = {
info: chalk.blue('ℹ'),
Expand All @@ -16,4 +15,6 @@ const fallback = {
error: chalk.red('×')
};

module.exports = isUnicodeSupported() ? main : fallback;
const logSymbols = isUnicodeSupported() ? main : fallback;

export default logSymbols;
2 changes: 1 addition & 1 deletion index.test-d.ts
@@ -1,5 +1,5 @@
import {expectType} from 'tsd';
import logSymbols = require('.');
import logSymbols from './index.js';

expectType<string>(logSymbols.info);
expectType<string>(logSymbols.success);
Expand Down
16 changes: 10 additions & 6 deletions package.json
Expand Up @@ -10,8 +10,13 @@
"email": "sindresorhus@gmail.com",
"url": "https://sindresorhus.com"
},
"type": "module",
"exports": {
"node": "./index.js",
"default": "./browser.js"
},
"engines": {
"node": ">=10"
"node": ">=12"
},
"scripts": {
"test": "xo && ava && tsd"
Expand Down Expand Up @@ -40,13 +45,12 @@
],
"dependencies": {
"chalk": "^4.1.0",
"is-unicode-supported": "^0.1.0"
"is-unicode-supported": "^1.0.0"
},
"devDependencies": {
"ava": "^2.4.0",
"strip-ansi": "^6.0.0",
"ava": "^3.15.0",
"strip-ansi": "^7.0.0",
"tsd": "^0.14.0",
"xo": "^0.38.2"
},
"browser": "browser.js"
}
}
2 changes: 1 addition & 1 deletion readme.md
Expand Up @@ -15,7 +15,7 @@ $ npm install log-symbols
## Usage

```js
const logSymbols = require('log-symbols');
import logSymbols from 'log-symbols';

console.log(logSymbols.success, 'Finished successfully!');
// Terminals with Unicode support: ✔ Finished successfully!
Expand Down
7 changes: 3 additions & 4 deletions test.js
@@ -1,7 +1,6 @@
'use strict';
const test = require('ava');
const stripAnsi = require('strip-ansi');
const logSymbols = require('.');
import test from 'ava';
import stripAnsi from 'strip-ansi';
import logSymbols from './index.js';

for (const [key, value] of Object.entries(logSymbols)) {
console.log(value, key);
Expand Down

0 comments on commit 3721d57

Please sign in to comment.