Skip to content

Commit bd19733

Browse files
pvdlggr2m
authored andcommitted
fix: Use Node 8 promisify instead of pify
1 parent 5fb0cfc commit bd19733

File tree

3 files changed

+26
-28
lines changed

3 files changed

+26
-28
lines changed

lib/load/parser-config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
const {promisify} = require('util');
12
const importFrom = require('import-from');
2-
const pify = require('pify');
33
const {mergeWith} = require('lodash');
44
const SemanticReleaseError = require('@semantic-release/error');
55
const conventionalChangelogAngular = require('conventional-changelog-angular');
@@ -33,7 +33,7 @@ module.exports = async ({preset, config, parserOpts}) => {
3333
}
3434

3535
if (typeof loadedConfig === 'function') {
36-
loadedConfig = await pify(loadedConfig)();
36+
loadedConfig = await promisify(loadedConfig)();
3737
} else {
3838
loadedConfig = await loadedConfig;
3939
}

package.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@
1616
"conventional-changelog-angular": "^1.4.0",
1717
"conventional-commits-parser": "^2.0.0",
1818
"import-from": "^2.1.0",
19-
"lodash": "^4.17.4",
20-
"pify": "^3.0.0"
19+
"lodash": "^4.17.4"
2120
},
2221
"devDependencies": {
2322
"ava": "^0.23.0",
@@ -40,8 +39,7 @@
4039
"nyc": "^11.1.0",
4140
"prettier": "^1.7.2",
4241
"rimraf": "^2.6.1",
43-
"semantic-release": "^8.0.0",
44-
"tempy": "^0.2.0"
42+
"semantic-release": "^8.0.0"
4543
},
4644
"engines": {
4745
"node": ">=4"

test/integration.test.js

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
1+
import {promisify} from 'util';
12
import test from 'ava';
2-
import pify from 'pify';
33
import SemanticReleaseError from '@semantic-release/error';
44
import commitAnalyzer from '../lib/index';
55

66
test('Parse with "conventional-changelog-angular" by default', async t => {
77
const commits = [{message: 'fix(scope1): First fix'}, {message: 'feat(scope2): Second feature'}];
8-
const releaseType = await pify(commitAnalyzer)({}, {commits});
8+
const releaseType = await promisify(commitAnalyzer)({}, {commits});
99

1010
t.is(releaseType, 'minor');
1111
});
1212

1313
test('Accept "preset" option', async t => {
1414
const commits = [{message: 'Fix: First fix (fixes #123)'}, {message: 'Update: Second feature (fixes #456)'}];
15-
const releaseType = await pify(commitAnalyzer)({preset: 'eslint'}, {commits});
15+
const releaseType = await promisify(commitAnalyzer)({preset: 'eslint'}, {commits});
1616

1717
t.is(releaseType, 'minor');
1818
});
1919

2020
test('Accept "config" option', async t => {
2121
const commits = [{message: 'Fix: First fix (fixes #123)'}, {message: 'Update: Second feature (fixes #456)'}];
22-
const releaseType = await pify(commitAnalyzer)({config: 'conventional-changelog-eslint'}, {commits});
22+
const releaseType = await promisify(commitAnalyzer)({config: 'conventional-changelog-eslint'}, {commits});
2323

2424
t.is(releaseType, 'minor');
2525
});
@@ -29,7 +29,7 @@ test('Accept a "parseOpts" object as option', async t => {
2929
{message: '##BUGFIX## First fix (fixes #123)'},
3030
{message: '##FEATURE## Second feature (fixes #456)'},
3131
];
32-
const releaseType = await pify(commitAnalyzer)(
32+
const releaseType = await promisify(commitAnalyzer)(
3333
{parserOpts: {headerPattern: /^##(.*?)## (.*)$/, headerCorrespondence: ['tag', 'shortDesc']}},
3434
{commits}
3535
);
@@ -39,7 +39,7 @@ test('Accept a "parseOpts" object as option', async t => {
3939

4040
test('Accept a partial "parseOpts" object as option', async t => {
4141
const commits = [{message: '##fix## First fix (fixes #123)'}, {message: '##Update## Second feature (fixes #456)'}];
42-
const releaseType = await pify(commitAnalyzer)(
42+
const releaseType = await promisify(commitAnalyzer)(
4343
{
4444
config: 'conventional-changelog-eslint',
4545
parserOpts: {headerPattern: /^##(.*?)## (.*)$/, headerCorrespondence: ['type', 'shortDesc']},
@@ -52,7 +52,7 @@ test('Accept a partial "parseOpts" object as option', async t => {
5252

5353
test('Accept a "releaseRules" option that reference a requierable module', async t => {
5454
const commits = [{message: 'fix(scope1): First fix'}, {message: 'feat(scope2): Second feature'}];
55-
const releaseType = await pify(commitAnalyzer)({releaseRules: './test/fixtures/release-rules'}, {commits});
55+
const releaseType = await promisify(commitAnalyzer)({releaseRules: './test/fixtures/release-rules'}, {commits});
5656

5757
t.is(releaseType, 'minor');
5858
});
@@ -62,21 +62,21 @@ test('Return "major" if there is a breaking change, using default releaseRules',
6262
{message: 'Fix: First fix (fixes #123)'},
6363
{message: 'Update: Second feature (fixes #456) \n\n BREAKING CHANGE: break something'},
6464
];
65-
const releaseType = await pify(commitAnalyzer)({preset: 'eslint'}, {commits});
65+
const releaseType = await promisify(commitAnalyzer)({preset: 'eslint'}, {commits});
6666

6767
t.is(releaseType, 'major');
6868
});
6969

7070
test('Return "patch" if there is only types set to "patch", using default releaseRules', async t => {
7171
const commits = [{message: 'fix: First fix (fixes #123)'}, {message: 'perf: perf improvement'}];
72-
const releaseType = await pify(commitAnalyzer)({}, {commits});
72+
const releaseType = await promisify(commitAnalyzer)({}, {commits});
7373

7474
t.is(releaseType, 'patch');
7575
});
7676

7777
test('Allow to use regex in "releaseRules" configuration', async t => {
7878
const commits = [{message: 'Chore: First chore (fixes #123)'}, {message: 'Docs: update README (fixes #456)'}];
79-
const releaseType = await pify(commitAnalyzer)(
79+
const releaseType = await promisify(commitAnalyzer)(
8080
{
8181
preset: 'eslint',
8282
releaseRules: [{tag: 'Chore', release: 'patch'}, {message: '/README/', release: 'minor'}],
@@ -89,14 +89,14 @@ test('Allow to use regex in "releaseRules" configuration', async t => {
8989

9090
test('Return "null" if no rule match', async t => {
9191
const commits = [{message: 'doc: doc update'}, {message: 'chore: Chore'}];
92-
const releaseType = await pify(commitAnalyzer)({}, {commits});
92+
const releaseType = await promisify(commitAnalyzer)({}, {commits});
9393

9494
t.is(releaseType, null);
9595
});
9696

9797
test('Process rules in order and apply highest match', async t => {
9898
const commits = [{message: 'Chore: First chore (fixes #123)'}, {message: 'Docs: update README (fixes #456)'}];
99-
const releaseType = await pify(commitAnalyzer)(
99+
const releaseType = await promisify(commitAnalyzer)(
100100
{preset: 'eslint', releaseRules: [{tag: 'Chore', release: 'minor'}, {tag: 'Chore', release: 'patch'}]},
101101
{commits}
102102
);
@@ -109,7 +109,7 @@ test('Process rules in order and apply highest match from config even if default
109109
{message: 'Chore: First chore (fixes #123)'},
110110
{message: 'Docs: update README (fixes #456) \n\n BREAKING CHANGE: break something'},
111111
];
112-
const releaseType = await pify(commitAnalyzer)(
112+
const releaseType = await promisify(commitAnalyzer)(
113113
{preset: 'eslint', releaseRules: [{tag: 'Chore', release: 'patch'}, {breaking: true, release: 'minor'}]},
114114
{commits}
115115
);
@@ -119,7 +119,7 @@ test('Process rules in order and apply highest match from config even if default
119119

120120
test('Use default "releaseRules" if none of provided match', async t => {
121121
const commits = [{message: 'Chore: First chore'}, {message: 'Update: new feature'}];
122-
const releaseType = await pify(commitAnalyzer)(
122+
const releaseType = await promisify(commitAnalyzer)(
123123
{preset: 'eslint', releaseRules: [{tag: 'Chore', release: 'patch'}]},
124124
{commits}
125125
);
@@ -129,14 +129,14 @@ test('Use default "releaseRules" if none of provided match', async t => {
129129

130130
test('Ignore malformatted commits and process valid ones', async t => {
131131
const commits = [{message: 'fix(scope1): First fix'}, {message: 'Feature => Invalid message'}];
132-
const releaseType = await pify(commitAnalyzer)({}, {commits});
132+
const releaseType = await promisify(commitAnalyzer)({}, {commits});
133133

134134
t.is(releaseType, 'patch');
135135
});
136136

137137
test('Throw "SemanticReleaseError" if "preset" doesn`t exist', async t => {
138138
const error = await t.throws(
139-
pify(commitAnalyzer)({preset: 'unknown-preset'}, {}),
139+
promisify(commitAnalyzer)({preset: 'unknown-preset'}, {}),
140140
/Preset: "unknown-preset" does not exist:/
141141
);
142142

@@ -146,7 +146,7 @@ test('Throw "SemanticReleaseError" if "preset" doesn`t exist', async t => {
146146

147147
test('Throw "SemanticReleaseError" if "releaseRules" is not an Array or a String', async t => {
148148
const error = await t.throws(
149-
pify(commitAnalyzer)({releaseRules: {}}, {}),
149+
promisify(commitAnalyzer)({releaseRules: {}}, {}),
150150
/Error in commit-analyzer configuration: "releaseRules" must be an array of rules/
151151
);
152152

@@ -156,7 +156,7 @@ test('Throw "SemanticReleaseError" if "releaseRules" is not an Array or a String
156156

157157
test('Throw "SemanticReleaseError" if "releaseRules" option reference a requierable module that is not an Array or a String', async t => {
158158
const error = await t.throws(
159-
pify(commitAnalyzer)({releaseRules: './test/fixtures/release-rules-invalid'}, {}),
159+
promisify(commitAnalyzer)({releaseRules: './test/fixtures/release-rules-invalid'}, {}),
160160
/Error in commit-analyzer configuration: "releaseRules" must be an array of rules/
161161
);
162162

@@ -167,7 +167,7 @@ test('Throw "SemanticReleaseError" if "releaseRules" option reference a requiera
167167
test('Throw "SemanticReleaseError" if "config" doesn`t exist', async t => {
168168
const commits = [{message: 'Fix: First fix (fixes #123)'}, {message: 'Update: Second feature (fixes #456)'}];
169169
const error = await t.throws(
170-
pify(commitAnalyzer)({config: 'unknown-config'}, {commits}),
170+
promisify(commitAnalyzer)({config: 'unknown-config'}, {commits}),
171171
/Config: "unknown-config" does not exist:/
172172
);
173173

@@ -177,7 +177,7 @@ test('Throw "SemanticReleaseError" if "config" doesn`t exist', async t => {
177177

178178
test('Throw "SemanticReleaseError" if "releaseRules" reference invalid commit type', async t => {
179179
const error = await t.throws(
180-
pify(commitAnalyzer)({preset: 'eslint', releaseRules: [{tag: 'Update', release: 'invalid'}]}, {}),
180+
promisify(commitAnalyzer)({preset: 'eslint', releaseRules: [{tag: 'Update', release: 'invalid'}]}, {}),
181181
/Error in commit-analyzer configuration: "invalid" is not a valid release type\. Valid values are:\[?.*\]/
182182
);
183183

@@ -188,7 +188,7 @@ test('Throw "SemanticReleaseError" if "releaseRules" reference invalid commit ty
188188
test('Handle error in "conventional-changelog-parser" and wrap in "SemanticReleaseError"', async t => {
189189
const commits = [{message: 'Fix: First fix (fixes #123)'}, {message: 'Update: Second feature (fixes #456)'}];
190190
const error = await t.throws(
191-
pify(commitAnalyzer)({parserOpts: {headerPattern: '\\'}}, {commits}),
191+
promisify(commitAnalyzer)({parserOpts: {headerPattern: '\\'}}, {commits}),
192192
/Error in conventional-changelog-parser: Invalid regular expression:/
193193
);
194194

@@ -197,7 +197,7 @@ test('Handle error in "conventional-changelog-parser" and wrap in "SemanticRelea
197197

198198
test('Accept an undefined "pluginConfig"', async t => {
199199
const commits = [{message: 'fix(scope1): First fix'}, {message: 'feat(scope2): Second feature'}];
200-
const releaseType = await pify(commitAnalyzer)(undefined, {commits});
200+
const releaseType = await promisify(commitAnalyzer)(undefined, {commits});
201201

202202
t.is(releaseType, 'minor');
203203
});

0 commit comments

Comments
 (0)