1
- import { promisify } from 'util' ;
2
1
import { writeJson , readFile , appendFile } from 'fs-extra' ;
3
2
import test from 'ava' ;
4
3
import execa from 'execa' ;
@@ -68,7 +67,7 @@ test.after.always(async () => {
68
67
test . serial ( 'Throws error if NPM token is invalid' , async t => {
69
68
process . env . NPM_TOKEN = 'wrong_token' ;
70
69
const error = await t . throws (
71
- promisify ( t . context . m . verifyConditions ) ( { } , { pkg : { name : 'invalid-token' } , logger : t . context . logger } )
70
+ t . context . m . verifyConditions ( { } , { pkg : { name : 'invalid-token' } , logger : t . context . logger } )
72
71
) ;
73
72
74
73
t . true ( error instanceof SemanticReleaseError ) ;
@@ -82,7 +81,7 @@ test.serial('Throws error if NPM token is invalid', async t => {
82
81
test . serial ( 'Verify npm auth and package' , async t => {
83
82
Object . assign ( process . env , npmRegistry . authEnv ) ;
84
83
const pkg = { name : 'valid-token' , publishConfig : { registry : npmRegistry . url } } ;
85
- await t . notThrows ( promisify ( t . context . m . verifyConditions ) ( { } , { pkg, logger : t . context . logger } ) ) ;
84
+ await t . notThrows ( t . context . m . verifyConditions ( { } , { pkg, logger : t . context . logger } ) ) ;
86
85
87
86
const npmrc = ( await readFile ( '.npmrc' ) ) . toString ( ) ;
88
87
t . regex ( npmrc , / _ a u t h = / ) ;
@@ -92,7 +91,7 @@ test.serial('Verify npm auth and package', async t => {
92
91
test . serial ( 'Return nothing if no version if published' , async t => {
93
92
Object . assign ( process . env , npmRegistry . authEnv ) ;
94
93
const pkg = { name : 'not-published' , publishConfig : { registry : npmRegistry . url } } ;
95
- const nextRelease = await promisify ( t . context . m . getLastRelease ) ( { } , { pkg, logger : t . context . logger } ) ;
94
+ const nextRelease = await t . context . m . getLastRelease ( { } , { pkg, logger : t . context . logger } ) ;
96
95
97
96
t . deepEqual ( nextRelease , { } ) ;
98
97
} ) ;
@@ -111,7 +110,7 @@ test.serial('Return last version published', async t => {
111
110
112
111
await execa ( 'npm' , [ 'publish' ] ) ;
113
112
114
- const nextRelease = await promisify ( t . context . m . getLastRelease ) ( { } , { pkg, logger : t . context . logger } ) ;
113
+ const nextRelease = await t . context . m . getLastRelease ( { } , { pkg, logger : t . context . logger } ) ;
115
114
t . is ( nextRelease . version , '1.0.0' ) ;
116
115
} ) ;
117
116
@@ -134,7 +133,7 @@ test.serial('Return last version published on a dist-tag', async t => {
134
133
// Publish version 1.1.0 on next
135
134
await execa ( 'npm' , [ 'publish' , '--tag=next' ] ) ;
136
135
137
- const nextRelease = await promisify ( t . context . m . getLastRelease ) ( { } , { pkg, logger : t . context . logger } ) ;
136
+ const nextRelease = await t . context . m . getLastRelease ( { } , { pkg, logger : t . context . logger } ) ;
138
137
t . is ( nextRelease . version , '1.1.0' ) ;
139
138
} ) ;
140
139
@@ -153,7 +152,7 @@ test.serial('Return nothing for an unpublished package', async t => {
153
152
await execa ( 'npm' , [ 'publish' ] ) ;
154
153
await execa ( 'npm' , [ 'unpublish' , 'unpublished' , '--force' ] ) ;
155
154
156
- const nextRelease = await promisify ( t . context . m . getLastRelease ) ( { } , { pkg, logger : t . context . logger } ) ;
155
+ const nextRelease = await t . context . m . getLastRelease ( { } , { pkg, logger : t . context . logger } ) ;
157
156
t . deepEqual ( nextRelease , { } ) ;
158
157
} ) ;
159
158
@@ -162,7 +161,7 @@ test.serial('Publish a package', async t => {
162
161
const pkg = { name : 'publish' , version : '1.0.0' , publishConfig : { registry : npmRegistry . url } } ;
163
162
await writeJson ( './package.json' , pkg ) ;
164
163
165
- await promisify ( t . context . m . publish ) ( { } , { pkg, logger : t . context . logger , nextRelease : { version : '1.0.0' } } ) ;
164
+ await t . context . m . publish ( { } , { pkg, logger : t . context . logger , nextRelease : { version : '1.0.0' } } ) ;
166
165
167
166
t . is ( ( await execa ( 'npm' , [ 'view' , 'publish' , 'version' ] ) ) . stdout , '1.0.0' ) ;
168
167
} ) ;
@@ -172,13 +171,13 @@ test.serial('Verify token and set up auth only on the fist call', async t => {
172
171
const pkg = { name : 'test-module' , version : '0.0.0-dev' , publishConfig : { registry : npmRegistry . url } } ;
173
172
await writeJson ( './package.json' , pkg ) ;
174
173
175
- await t . notThrows ( promisify ( t . context . m . verifyConditions ) ( { } , { pkg, logger : t . context . logger } ) ) ;
174
+ await t . notThrows ( t . context . m . verifyConditions ( { } , { pkg, logger : t . context . logger } ) ) ;
176
175
177
- let nextRelease = await promisify ( t . context . m . getLastRelease ) ( { } , { pkg, logger : t . context . logger } ) ;
176
+ let nextRelease = await t . context . m . getLastRelease ( { } , { pkg, logger : t . context . logger } ) ;
178
177
t . deepEqual ( nextRelease , { } ) ;
179
178
180
- await promisify ( t . context . m . publish ) ( { } , { pkg, logger : t . context . logger , nextRelease : { version : '1.0.0' } } ) ;
179
+ await t . context . m . publish ( { } , { pkg, logger : t . context . logger , nextRelease : { version : '1.0.0' } } ) ;
181
180
182
- nextRelease = await promisify ( t . context . m . getLastRelease ) ( { } , { pkg, logger : t . context . logger } ) ;
181
+ nextRelease = await t . context . m . getLastRelease ( { } , { pkg, logger : t . context . logger } ) ;
183
182
t . is ( nextRelease . version , '1.0.0' ) ;
184
183
} ) ;
0 commit comments