Skip to content

Commit

Permalink
Meta tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Jul 12, 2019
1 parent af4a078 commit 655653b
Show file tree
Hide file tree
Showing 16 changed files with 19 additions and 24 deletions.
2 changes: 2 additions & 0 deletions index.d.ts
Expand Up @@ -78,6 +78,8 @@ declare namespace chalk {
@example
```
import chalk = require('chalk');
log(chalk`
CPU: {red ${cpu.totalPercent}%}
RAM: {green ${ram.used / ram.total * 100}%}
Expand Down
5 changes: 2 additions & 3 deletions package.json
Expand Up @@ -4,6 +4,7 @@
"description": "Terminal string styling done right",
"license": "MIT",
"repository": "chalk/chalk",
"main": "source",
"engines": {
"node": ">=8"
},
Expand All @@ -12,8 +13,7 @@
"bench": "matcha benchmark.js"
},
"files": [
"index.js",
"templates.js",
"source",
"index.d.ts"
],
"keywords": [
Expand Down Expand Up @@ -44,7 +44,6 @@
"supports-color": "^6.1.0"
},
"devDependencies": {
"@sindresorhus/tsconfig": "^0.3.0",
"ava": "^1.4.1",
"coveralls": "^3.0.3",
"execa": "^1.0.0",
Expand Down
4 changes: 2 additions & 2 deletions readme.md
Expand Up @@ -220,8 +220,8 @@ const miles = 18;
const calculateFeet = miles => miles * 5280;

console.log(chalk`
There are {bold 5280 feet} in a mile.
In {bold ${miles} miles}, there are {green.bold ${calculateFeet(miles)} feet}.
There are {bold 5280 feet} in a mile.
In {bold ${miles} miles}, there are {green.bold ${calculateFeet(miles)} feet}.
`);
```

Expand Down
5 changes: 2 additions & 3 deletions index.js → source/index.js
@@ -1,12 +1,11 @@
'use strict';
const ansiStyles = require('ansi-styles');
const {stdout: stdoutColor} = require('supports-color');
const template = require('./templates.js');

const template = require('./templates');
const {
stringReplaceAll,
stringEncaseCRLFWithFirstIndex
} = require('./lib/util');
} = require('./util');

// `supportsColor.level` → `ansiStyles.color[name]` mapping
const levelMapping = [
Expand Down
File renamed without changes.
2 changes: 2 additions & 0 deletions lib/util.js → source/util.js
@@ -1,3 +1,5 @@
'use strict';

const stringReplaceAll = (string, substring, replacer) => {
let index = string.indexOf(substring);
if (index === -1) {
Expand Down
2 changes: 1 addition & 1 deletion test/_fixture.js
@@ -1,4 +1,4 @@
'use strict';
const chalk = require('..');
const chalk = require('../source');

console.log(chalk.hex('#ff6159')('test'));
2 changes: 1 addition & 1 deletion test/chalk.js
Expand Up @@ -3,7 +3,7 @@ import test from 'ava';
// Spoof supports-color
require('./_supports-color')(__dirname);

const chalk = require('..');
const chalk = require('../source');

console.log('TERM:', process.env.TERM || '[none]');
console.log('platform:', process.platform || '[unknown]');
Expand Down
2 changes: 1 addition & 1 deletion test/constructor.js
@@ -1,6 +1,6 @@
import test from 'ava';

const chalk = require('..');
const chalk = require('../source');

test('Chalk.constructor should throw an expected error', t => {
const expectedError = t.throws(() => {
Expand Down
2 changes: 1 addition & 1 deletion test/enabled.js
Expand Up @@ -3,7 +3,7 @@ import test from 'ava';
// Spoof supports-color
require('./_supports-color')(__dirname);

const chalk = require('..');
const chalk = require('../source');

test('don\'t output colors when manually disabled', t => {
chalk.enabled = false;
Expand Down
2 changes: 1 addition & 1 deletion test/instance.js
Expand Up @@ -3,7 +3,7 @@ import test from 'ava';
// Spoof supports-color
require('./_supports-color')(__dirname);

const chalk = require('..');
const chalk = require('../source');

test('create an isolated context where colors can be disabled (by level)', t => {
const instance = new chalk.Instance({level: 0, enabled: true});
Expand Down
2 changes: 1 addition & 1 deletion test/level.js
Expand Up @@ -5,7 +5,7 @@ import execa from 'execa';
// Spoof supports-color
require('./_supports-color')(__dirname);

const chalk = require('..');
const chalk = require('../source');

test('don\'t output colors when manually disabled', t => {
const oldLevel = chalk.level;
Expand Down
2 changes: 1 addition & 1 deletion test/no-color-support.js
Expand Up @@ -8,7 +8,7 @@ require('./_supports-color')(__dirname, {
has16m: false
});

const chalk = require('..');
const chalk = require('../source');

test.failing('colors can be forced by using chalk.enabled', t => {
chalk.enabled = true;
Expand Down
2 changes: 1 addition & 1 deletion test/template-literal.js
Expand Up @@ -4,7 +4,7 @@ import test from 'ava';
// Spoof supports-color
require('./_supports-color')(__dirname);

const chalk = require('..');
const chalk = require('../source');

test('return an empty string for an empty literal', t => {
const instance = new chalk.Instance();
Expand Down
2 changes: 1 addition & 1 deletion test/visible.js
Expand Up @@ -3,7 +3,7 @@ import test from 'ava';
// Spoof supports-color
require('./_supports-color')(__dirname);

const chalk = require('..');
const chalk = require('../source');

test('visible: normal output when enabled', t => {
const instance = new chalk.Instance({level: 3, enabled: true});
Expand Down
7 changes: 0 additions & 7 deletions tsconfig.json

This file was deleted.

0 comments on commit 655653b

Please sign in to comment.