Skip to content

Commit fa16f4e

Browse files
committed
Require Node.js 12 and move to ESM
1 parent 4dab5e1 commit fa16f4e

22 files changed

+388
-438
lines changed

.github/funding.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
github: [sindresorhus,Qix-]
1+
github: [sindresorhus, Qix-]
22
open_collective: sindresorhus
33
tidelift: npm/chalk
44
custom: https://sindresorhus.com/donate

.github/workflows/main.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@ jobs:
1212
node-version:
1313
- 14
1414
- 12
15-
- 10
1615
steps:
1716
- uses: actions/checkout@v2
18-
- uses: actions/setup-node@v1
17+
- uses: actions/setup-node@v2
1918
with:
2019
node-version: ${{ matrix.node-version }}
2120
- run: npm install

benchmark.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
/* globals suite, bench */
2-
'use strict';
3-
const chalk = require('.');
2+
import chalk from './index.js';
43

54
suite('chalk', () => {
65
const chalkRed = chalk.red;

examples/rainbow.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
'use strict';
2-
const chalk = require('..');
1+
import chalk from '../index.js';
32

43
const ignoreChars = /[^!-~]/g;
54

@@ -17,7 +16,7 @@ function rainbow(string, offset) {
1716
let hue = offset % 360;
1817
const characters = [];
1918
for (const character of string) {
20-
if (character.match(ignoreChars)) {
19+
if (ignoreChars.test(character)) {
2120
characters.push(character);
2221
} else {
2322
characters.push(chalk.hsl(hue, 100, 50)(character));
@@ -30,8 +29,8 @@ function rainbow(string, offset) {
3029

3130
async function animateString(string) {
3231
console.log();
33-
for (let i = 0; i < 360 * 5; i++) {
34-
console.log('\u001B[1F\u001B[G', rainbow(string, i));
32+
for (let index = 0; index < 360 * 5; index++) {
33+
console.log('\u001B[1F\u001B[G', rainbow(string, index));
3534
await delay(2); // eslint-disable-line no-await-in-loop
3635
}
3736
}

examples/screenshot.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
'use strict';
2-
const styles = require('ansi-styles');
3-
const chalk = require('..');
1+
import styles from 'ansi-styles';
2+
import chalk from '../index.js';
43

54
// Generates screenshot
65
for (const key of Object.keys(styles)) {

0 commit comments

Comments
 (0)