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 16, 2021
1 parent 4dab5e1 commit fa16f4e
Show file tree
Hide file tree
Showing 22 changed files with 388 additions and 438 deletions.
2 changes: 1 addition & 1 deletion .github/funding.yml
@@ -1,4 +1,4 @@
github: [sindresorhus,Qix-]
github: [sindresorhus, Qix-]
open_collective: sindresorhus
tidelift: npm/chalk
custom: https://sindresorhus.com/donate
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
3 changes: 1 addition & 2 deletions benchmark.js
@@ -1,6 +1,5 @@
/* globals suite, bench */
'use strict';
const chalk = require('.');
import chalk from './index.js';

suite('chalk', () => {
const chalkRed = chalk.red;
Expand Down
9 changes: 4 additions & 5 deletions examples/rainbow.js
@@ -1,5 +1,4 @@
'use strict';
const chalk = require('..');
import chalk from '../index.js';

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

Expand All @@ -17,7 +16,7 @@ function rainbow(string, offset) {
let hue = offset % 360;
const characters = [];
for (const character of string) {
if (character.match(ignoreChars)) {
if (ignoreChars.test(character)) {
characters.push(character);
} else {
characters.push(chalk.hsl(hue, 100, 50)(character));
Expand All @@ -30,8 +29,8 @@ function rainbow(string, offset) {

async function animateString(string) {
console.log();
for (let i = 0; i < 360 * 5; i++) {
console.log('\u001B[1F\u001B[G', rainbow(string, i));
for (let index = 0; index < 360 * 5; index++) {
console.log('\u001B[1F\u001B[G', rainbow(string, index));
await delay(2); // eslint-disable-line no-await-in-loop
}
}
Expand Down
5 changes: 2 additions & 3 deletions examples/screenshot.js
@@ -1,6 +1,5 @@
'use strict';
const styles = require('ansi-styles');
const chalk = require('..');
import styles from 'ansi-styles';
import chalk from '../index.js';

// Generates screenshot
for (const key of Object.keys(styles)) {
Expand Down

0 comments on commit fa16f4e

Please sign in to comment.