release-it 19.0.0-next.0 → 19.0.0-next.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/test/log.js CHANGED
@@ -1,143 +1,146 @@
1
1
  import { EOL } from 'node:os';
2
- import test from 'ava';
2
+ import test, { describe } from 'node:test';
3
+ import assert from 'node:assert/strict';
4
+ import { stripVTControlCharacters } from 'node:util';
3
5
  import mockStdIo from 'mock-stdio';
4
- import stripAnsi from 'strip-ansi';
5
6
  import Log from '../lib/log.js';
6
7
 
7
- test('should write to stdout', t => {
8
- const log = new Log();
9
- mockStdIo.start();
10
- log.log('foo');
11
- const { stdout, stderr } = mockStdIo.end();
12
- t.is(stdout, 'foo\n');
13
- t.is(stderr, '');
14
- });
15
-
16
- test('should write to stderr', t => {
17
- const log = new Log();
18
- mockStdIo.start();
19
- log.error('foo');
20
- const { stdout, stderr } = mockStdIo.end();
21
- t.is(stdout, '');
22
- t.is(stripAnsi(stderr), 'ERROR foo\n');
23
- });
24
-
25
- test('should print a warning', t => {
26
- const log = new Log();
27
- mockStdIo.start();
28
- log.warn('foo');
29
- const { stdout } = mockStdIo.end();
30
- t.is(stripAnsi(stdout), 'WARNING foo\n');
31
- });
32
-
33
- test('should print verbose', t => {
34
- const log = new Log({ isVerbose: true, verbosityLevel: 2 });
35
- mockStdIo.start();
36
- log.verbose('foo');
37
- const { stdout } = mockStdIo.end();
38
- t.is(stdout, 'foo\n');
39
- });
40
-
41
- test('should print external scripts verbose', t => {
42
- const log = new Log({ isVerbose: true });
43
- mockStdIo.start();
44
- log.verbose('foo', { isExternal: true });
45
- const { stdout } = mockStdIo.end();
46
- t.is(stdout, 'foo\n');
47
- });
48
-
49
- test('should always print external scripts verbose', t => {
50
- const log = new Log({ isVerbose: true, verbosityLevel: 2 });
51
- mockStdIo.start();
52
- log.verbose('foo', { isExternal: true });
53
- const { stdout } = mockStdIo.end();
54
- t.is(stdout, 'foo\n');
55
- });
56
-
57
- test('should not print verbose by default', t => {
58
- const log = new Log();
59
- mockStdIo.start();
60
- log.verbose('foo');
61
- const { stdout } = mockStdIo.end();
62
- t.is(stdout, '');
63
- });
64
-
65
- test('should not print command execution by default', t => {
66
- const log = new Log();
67
- mockStdIo.start();
68
- log.exec('foo');
69
- const { stdout } = mockStdIo.end();
70
- t.is(stdout.trim(), '');
71
- });
72
-
73
- test('should print command execution (verbose)', t => {
74
- const log = new Log({ isVerbose: true, verbosityLevel: 2 });
75
- mockStdIo.start();
76
- log.exec('foo');
77
- const { stdout } = mockStdIo.end();
78
- t.is(stdout.trim(), '$ foo');
79
- });
80
-
81
- test('should print command execution (verbose/dry run)', t => {
82
- const log = new Log({ isVerbose: true });
83
- mockStdIo.start();
84
- log.exec('foo', { isDryRun: true, isExternal: true });
85
- const { stdout } = mockStdIo.end();
86
- t.is(stdout.trim(), '! foo');
87
- });
88
-
89
- test('should print command execution (verbose/external)', t => {
90
- const log = new Log({ isVerbose: true });
91
- mockStdIo.start();
92
- log.exec('foo', { isExternal: true });
93
- const { stdout } = mockStdIo.end();
94
- t.is(stdout.trim(), '$ foo');
95
- });
96
-
97
- test('should print command execution (dry run)', t => {
98
- const log = new Log({ isDryRun: true });
99
- mockStdIo.start();
100
- log.exec('foo');
101
- const { stdout } = mockStdIo.end();
102
- t.is(stdout, '$ foo\n');
103
- });
104
-
105
- test('should print command execution (read-only)', t => {
106
- const log = new Log({ isDryRun: true });
107
- mockStdIo.start();
108
- log.exec('foo', 'bar', false);
109
- const { stdout } = mockStdIo.end();
110
- t.is(stdout, '$ foo bar\n');
111
- });
112
-
113
- test('should print command execution (write)', t => {
114
- const log = new Log({ isDryRun: true });
115
- mockStdIo.start();
116
- log.exec('foo', '--arg n', { isDryRun: true });
117
- const { stdout } = mockStdIo.end();
118
- t.is(stdout, '! foo --arg n\n');
119
- });
120
-
121
- test('should print obtrusive', t => {
122
- const log = new Log({ isCI: false });
123
- mockStdIo.start();
124
- log.obtrusive('spacious');
125
- const { stdout } = mockStdIo.end();
126
- t.is(stdout, '\nspacious\n\n');
127
- });
128
-
129
- test('should not print obtrusive in CI mode', t => {
130
- const log = new Log({ isCI: true });
131
- mockStdIo.start();
132
- log.obtrusive('normal');
133
- const { stdout } = mockStdIo.end();
134
- t.is(stdout, 'normal\n');
135
- });
136
-
137
- test('should print preview', t => {
138
- const log = new Log();
139
- mockStdIo.start();
140
- log.preview({ title: 'title', text: 'changelog' });
141
- const { stdout } = mockStdIo.end();
142
- t.is(stripAnsi(stdout), `Title:${EOL}changelog\n`);
8
+ describe('log', () => {
9
+ test('should write to stdout', () => {
10
+ const log = new Log();
11
+ mockStdIo.start();
12
+ log.log('foo');
13
+ const { stdout, stderr } = mockStdIo.end();
14
+ assert.equal(stdout, 'foo\n');
15
+ assert.equal(stderr, '');
16
+ });
17
+
18
+ test('should write to stderr', () => {
19
+ const log = new Log();
20
+ mockStdIo.start();
21
+ log.error('foo');
22
+ const { stdout, stderr } = mockStdIo.end();
23
+ assert.equal(stdout, '');
24
+ assert.equal(stripVTControlCharacters(stderr), 'ERROR foo\n');
25
+ });
26
+
27
+ test('should print a warning', () => {
28
+ const log = new Log();
29
+ mockStdIo.start();
30
+ log.warn('foo');
31
+ const { stderr } = mockStdIo.end();
32
+ assert.equal(stripVTControlCharacters(stderr), 'WARNING foo\n');
33
+ });
34
+
35
+ test('should print verbose', () => {
36
+ const log = new Log({ isVerbose: true, verbosityLevel: 2 });
37
+ mockStdIo.start();
38
+ log.verbose('foo');
39
+ const { stderr } = mockStdIo.end();
40
+ assert.equal(stderr, 'foo\n');
41
+ });
42
+
43
+ test('should print external scripts verbose', () => {
44
+ const log = new Log({ isVerbose: true });
45
+ mockStdIo.start();
46
+ log.verbose('foo', { isExternal: true });
47
+ const { stderr } = mockStdIo.end();
48
+ assert.equal(stderr, 'foo\n');
49
+ });
50
+
51
+ test('should always print external scripts verbose', () => {
52
+ const log = new Log({ isVerbose: true, verbosityLevel: 2 });
53
+ mockStdIo.start();
54
+ log.verbose('foo', { isExternal: true });
55
+ const { stderr } = mockStdIo.end();
56
+ assert.equal(stderr, 'foo\n');
57
+ });
58
+
59
+ test('should not print verbose by default', () => {
60
+ const log = new Log();
61
+ mockStdIo.start();
62
+ log.verbose('foo');
63
+ const { stderr } = mockStdIo.end();
64
+ assert.equal(stderr, '');
65
+ });
66
+
67
+ test('should not print command execution by default', () => {
68
+ const log = new Log();
69
+ mockStdIo.start();
70
+ log.exec('foo');
71
+ const { stderr } = mockStdIo.end();
72
+ assert.equal(stderr.trim(), '');
73
+ });
74
+
75
+ test('should print command execution (verbose)', () => {
76
+ const log = new Log({ isVerbose: true, verbosityLevel: 2 });
77
+ mockStdIo.start();
78
+ log.exec('foo');
79
+ const { stderr } = mockStdIo.end();
80
+ assert.equal(stderr.trim(), '$ foo');
81
+ });
82
+
83
+ test('should print command execution (verbose/dry run)', () => {
84
+ const log = new Log({ isVerbose: true });
85
+ mockStdIo.start();
86
+ log.exec('foo', { isDryRun: true, isExternal: true });
87
+ const { stderr } = mockStdIo.end();
88
+ assert.equal(stderr.trim(), '! foo');
89
+ });
90
+
91
+ test('should print command execution (verbose/external)', () => {
92
+ const log = new Log({ isVerbose: true });
93
+ mockStdIo.start();
94
+ log.exec('foo', { isExternal: true });
95
+ const { stderr } = mockStdIo.end();
96
+ assert.equal(stderr.trim(), '$ foo');
97
+ });
98
+
99
+ test('should print command execution (dry run)', () => {
100
+ const log = new Log({ isDryRun: true });
101
+ mockStdIo.start();
102
+ log.exec('foo');
103
+ const { stderr } = mockStdIo.end();
104
+ assert.equal(stderr, '$ foo\n');
105
+ });
106
+
107
+ test('should print command execution (read-only)', () => {
108
+ const log = new Log({ isDryRun: true });
109
+ mockStdIo.start();
110
+ log.exec('foo', 'bar', false);
111
+ const { stderr } = mockStdIo.end();
112
+ assert.equal(stderr, '$ foo bar\n');
113
+ });
114
+
115
+ test('should print command execution (write)', () => {
116
+ const log = new Log({ isDryRun: true });
117
+ mockStdIo.start();
118
+ log.exec('foo', '--arg n', { isDryRun: true });
119
+ const { stderr } = mockStdIo.end();
120
+ assert.equal(stderr, '! foo --arg n\n');
121
+ });
122
+
123
+ test('should print obtrusive', () => {
124
+ const log = new Log({ isCI: false });
125
+ mockStdIo.start();
126
+ log.obtrusive('spacious');
127
+ const { stdout } = mockStdIo.end();
128
+ assert.equal(stdout, '\nspacious\n\n');
129
+ });
130
+
131
+ test('should not print obtrusive in CI mode', () => {
132
+ const log = new Log({ isCI: true });
133
+ mockStdIo.start();
134
+ log.obtrusive('normal');
135
+ const { stdout } = mockStdIo.end();
136
+ assert.equal(stdout, 'normal\n');
137
+ });
138
+
139
+ test('should print preview', () => {
140
+ const log = new Log();
141
+ mockStdIo.start();
142
+ log.preview({ title: 'title', text: 'changelog' });
143
+ const { stdout } = mockStdIo.end();
144
+ assert.equal(stripVTControlCharacters(stdout), `Title:${EOL}changelog\n`);
145
+ });
143
146
  });