Meta tweaks

This commit is contained in:
Sindre Sorhus 2019-07-12 13:51:07 +07:00
parent af4a078245
commit 655653bb0c
16 changed files with 19 additions and 24 deletions

2
index.d.ts vendored
View file

@ -78,6 +78,8 @@ declare namespace chalk {
@example @example
``` ```
import chalk = require('chalk');
log(chalk` log(chalk`
CPU: {red ${cpu.totalPercent}%} CPU: {red ${cpu.totalPercent}%}
RAM: {green ${ram.used / ram.total * 100}%} RAM: {green ${ram.used / ram.total * 100}%}

View file

@ -4,6 +4,7 @@
"description": "Terminal string styling done right", "description": "Terminal string styling done right",
"license": "MIT", "license": "MIT",
"repository": "chalk/chalk", "repository": "chalk/chalk",
"main": "source",
"engines": { "engines": {
"node": ">=8" "node": ">=8"
}, },
@ -12,8 +13,7 @@
"bench": "matcha benchmark.js" "bench": "matcha benchmark.js"
}, },
"files": [ "files": [
"index.js", "source",
"templates.js",
"index.d.ts" "index.d.ts"
], ],
"keywords": [ "keywords": [
@ -44,7 +44,6 @@
"supports-color": "^6.1.0" "supports-color": "^6.1.0"
}, },
"devDependencies": { "devDependencies": {
"@sindresorhus/tsconfig": "^0.3.0",
"ava": "^1.4.1", "ava": "^1.4.1",
"coveralls": "^3.0.3", "coveralls": "^3.0.3",
"execa": "^1.0.0", "execa": "^1.0.0",

View file

@ -220,8 +220,8 @@ const miles = 18;
const calculateFeet = miles => miles * 5280; const calculateFeet = miles => miles * 5280;
console.log(chalk` console.log(chalk`
There are {bold 5280 feet} in a mile. There are {bold 5280 feet} in a mile.
In {bold ${miles} miles}, there are {green.bold ${calculateFeet(miles)} feet}. In {bold ${miles} miles}, there are {green.bold ${calculateFeet(miles)} feet}.
`); `);
``` ```

View file

@ -1,12 +1,11 @@
'use strict'; 'use strict';
const ansiStyles = require('ansi-styles'); const ansiStyles = require('ansi-styles');
const {stdout: stdoutColor} = require('supports-color'); const {stdout: stdoutColor} = require('supports-color');
const template = require('./templates.js'); const template = require('./templates');
const { const {
stringReplaceAll, stringReplaceAll,
stringEncaseCRLFWithFirstIndex stringEncaseCRLFWithFirstIndex
} = require('./lib/util'); } = require('./util');
// `supportsColor.level` → `ansiStyles.color[name]` mapping // `supportsColor.level` → `ansiStyles.color[name]` mapping
const levelMapping = [ const levelMapping = [

View file

@ -1,3 +1,5 @@
'use strict';
const stringReplaceAll = (string, substring, replacer) => { const stringReplaceAll = (string, substring, replacer) => {
let index = string.indexOf(substring); let index = string.indexOf(substring);
if (index === -1) { if (index === -1) {

View file

@ -1,4 +1,4 @@
'use strict'; 'use strict';
const chalk = require('..'); const chalk = require('../source');
console.log(chalk.hex('#ff6159')('test')); console.log(chalk.hex('#ff6159')('test'));

View file

@ -3,7 +3,7 @@ import test from 'ava';
// Spoof supports-color // Spoof supports-color
require('./_supports-color')(__dirname); require('./_supports-color')(__dirname);
const chalk = require('..'); const chalk = require('../source');
console.log('TERM:', process.env.TERM || '[none]'); console.log('TERM:', process.env.TERM || '[none]');
console.log('platform:', process.platform || '[unknown]'); console.log('platform:', process.platform || '[unknown]');

View file

@ -1,6 +1,6 @@
import test from 'ava'; import test from 'ava';
const chalk = require('..'); const chalk = require('../source');
test('Chalk.constructor should throw an expected error', t => { test('Chalk.constructor should throw an expected error', t => {
const expectedError = t.throws(() => { const expectedError = t.throws(() => {

View file

@ -3,7 +3,7 @@ import test from 'ava';
// Spoof supports-color // Spoof supports-color
require('./_supports-color')(__dirname); require('./_supports-color')(__dirname);
const chalk = require('..'); const chalk = require('../source');
test('don\'t output colors when manually disabled', t => { test('don\'t output colors when manually disabled', t => {
chalk.enabled = false; chalk.enabled = false;

View file

@ -3,7 +3,7 @@ import test from 'ava';
// Spoof supports-color // Spoof supports-color
require('./_supports-color')(__dirname); require('./_supports-color')(__dirname);
const chalk = require('..'); const chalk = require('../source');
test('create an isolated context where colors can be disabled (by level)', t => { test('create an isolated context where colors can be disabled (by level)', t => {
const instance = new chalk.Instance({level: 0, enabled: true}); const instance = new chalk.Instance({level: 0, enabled: true});

View file

@ -5,7 +5,7 @@ import execa from 'execa';
// Spoof supports-color // Spoof supports-color
require('./_supports-color')(__dirname); require('./_supports-color')(__dirname);
const chalk = require('..'); const chalk = require('../source');
test('don\'t output colors when manually disabled', t => { test('don\'t output colors when manually disabled', t => {
const oldLevel = chalk.level; const oldLevel = chalk.level;

View file

@ -8,7 +8,7 @@ require('./_supports-color')(__dirname, {
has16m: false has16m: false
}); });
const chalk = require('..'); const chalk = require('../source');
test.failing('colors can be forced by using chalk.enabled', t => { test.failing('colors can be forced by using chalk.enabled', t => {
chalk.enabled = true; chalk.enabled = true;

View file

@ -4,7 +4,7 @@ import test from 'ava';
// Spoof supports-color // Spoof supports-color
require('./_supports-color')(__dirname); require('./_supports-color')(__dirname);
const chalk = require('..'); const chalk = require('../source');
test('return an empty string for an empty literal', t => { test('return an empty string for an empty literal', t => {
const instance = new chalk.Instance(); const instance = new chalk.Instance();

View file

@ -3,7 +3,7 @@ import test from 'ava';
// Spoof supports-color // Spoof supports-color
require('./_supports-color')(__dirname); require('./_supports-color')(__dirname);
const chalk = require('..'); const chalk = require('../source');
test('visible: normal output when enabled', t => { test('visible: normal output when enabled', t => {
const instance = new chalk.Instance({level: 3, enabled: true}); const instance = new chalk.Instance({level: 3, enabled: true});

View file

@ -1,7 +0,0 @@
{
"extends": "@sindresorhus/tsconfig",
"compilerOptions": {
"noEmit": true,
"allowJs": true
}
}