Skip to content

Commit f2ad2f5

Browse files
committed
build(deps): -fs-extra
1 parent 942ddb2 commit f2ad2f5

File tree

9 files changed

+1706
-333
lines changed

9 files changed

+1706
-333
lines changed

index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,3 @@ export async function fail(pluginConfig, context) {
6464

6565
await failGitHub(pluginConfig, context);
6666
}
67-

lib/glob-assets.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export default async function globAssets({cwd}, assets) {
1414
assets.map(async (asset) => {
1515
// Wrap single glob definition in Array
1616
let glob = castArray(isPlainObject(asset) ? asset.path : asset);
17+
1718
// TODO Temporary workaround for https://github.com/mrmlnc/fast-glob/issues/47
1819
glob = uniq([...(await dirGlob(glob, {cwd})), ...glob]);
1920

lib/publish.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {resolve, basename, extname} from 'node:path';
2+
import {stat, readFile} from 'node:fs/promises';
23

3-
import {stat, readFile} from 'fs-extra';
44
import {isPlainObject, template} from 'lodash-es';
55
import {getType} from 'mime';
66
import debugFactory from 'debug';

package-lock.json

Lines changed: 1664 additions & 286 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
"bottleneck": "^2.18.1",
2727
"debug": "^4.0.0",
2828
"dir-glob": "^3.0.0",
29-
"fs-extra": "^10.0.0",
3029
"globby": "^12.0.2",
3130
"http-proxy-agent": "^5.0.0",
3231
"https-proxy-agent": "^5.0.0",
@@ -40,8 +39,8 @@
4039
"devDependencies": {
4140
"ava": "4.0.0-alpha.2",
4241
"c8": "7.9.0",
43-
"clear-module": "4.1.1",
4442
"codecov": "3.8.3",
43+
"cpy": "^8.1.2",
4544
"nock": "13.1.3",
4645
"proxy": "1.0.2",
4746
"proxyquire": "2.1.3",

test/add-channel.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import * as RATE_LIMIT from './helpers/rate-limit.js';
99
/* eslint camelcase: ["error", {properties: "never"}] */
1010

1111
// mock rate limit imported via lib/get-client.js
12-
await quibble.esm('../lib/definitions/rate-limit.js', RATE_LIMIT)
12+
await quibble.esm('../lib/definitions/rate-limit.js', RATE_LIMIT) // eslint-disable-line
1313
const addChannel = (await import('../lib/add-channel.js')).default
1414

1515
test.beforeEach((t) => {

test/glob-assets.test.js

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import {resolve} from 'node:path';
2+
import {mkdir} from 'node:fs/promises';
23

34
import test from 'ava';
4-
import {copy, ensureDir} from 'fs-extra';
55
import {isPlainObject, sortBy} from 'lodash-es';
66
import tempy from 'tempy';
7+
import cpy from 'cpy';
78

89
import globAssets from '../lib/glob-assets.js';
910

@@ -13,31 +14,31 @@ const fixtures = 'test/fixtures/files';
1314

1415
test('Retrieve file from single path', async (t) => {
1516
const cwd = tempy.directory();
16-
await copy(fixtures, cwd);
17+
await cpy(fixtures, cwd, {dot: true});
1718
const globbedAssets = await globAssets({cwd}, ['upload.txt']);
1819

1920
t.deepEqual(globbedAssets, ['upload.txt']);
2021
});
2122

2223
test('Retrieve multiple files from path', async (t) => {
2324
const cwd = tempy.directory();
24-
await copy(fixtures, cwd);
25+
await cpy(fixtures, cwd, {dot: true});
2526
const globbedAssets = await globAssets({cwd}, ['upload.txt', 'upload_other.txt']);
2627

2728
t.deepEqual(sortAssets(globbedAssets), sortAssets(['upload_other.txt', 'upload.txt']));
2829
});
2930

3031
test('Include missing files as defined, using Object definition', async (t) => {
3132
const cwd = tempy.directory();
32-
await copy(fixtures, cwd);
33+
await cpy(fixtures, cwd, {dot: true});
3334
const globbedAssets = await globAssets({cwd}, ['upload.txt', {path: 'miss*.txt', label: 'Missing'}]);
3435

3536
t.deepEqual(sortAssets(globbedAssets), sortAssets(['upload.txt', {path: 'miss*.txt', label: 'Missing'}]));
3637
});
3738

3839
test('Retrieve multiple files from Object', async (t) => {
3940
const cwd = tempy.directory();
40-
await copy(fixtures, cwd);
41+
await cpy(fixtures, cwd, {dot: true});
4142
const globbedAssets = await globAssets({cwd}, [
4243
{path: 'upload.txt', name: 'upload_name', label: 'Upload label'},
4344
'upload_other.txt',
@@ -51,7 +52,7 @@ test('Retrieve multiple files from Object', async (t) => {
5152

5253
test('Retrieve multiple files without duplicates', async (t) => {
5354
const cwd = tempy.directory();
54-
await copy(fixtures, cwd);
55+
await cpy(fixtures, cwd, {dot: true});
5556
const globbedAssets = await globAssets({cwd}, [
5657
'upload_other.txt',
5758
'upload.txt',
@@ -66,7 +67,7 @@ test('Retrieve multiple files without duplicates', async (t) => {
6667

6768
test('Favor Object over String values when removing duplicates', async (t) => {
6869
const cwd = tempy.directory();
69-
await copy(fixtures, cwd);
70+
await cpy(fixtures, cwd, {dot: true});
7071
const globbedAssets = await globAssets({cwd}, [
7172
'upload_other.txt',
7273
'upload.txt',
@@ -88,47 +89,47 @@ test('Favor Object over String values when removing duplicates', async (t) => {
8889

8990
test('Retrieve file from single glob', async (t) => {
9091
const cwd = tempy.directory();
91-
await copy(fixtures, cwd);
92+
await cpy(fixtures, cwd, {dot: true});
9293
const globbedAssets = await globAssets({cwd}, ['upload.*']);
9394

9495
t.deepEqual(globbedAssets, ['upload.txt']);
9596
});
9697

9798
test('Retrieve multiple files from single glob', async (t) => {
9899
const cwd = tempy.directory();
99-
await copy(fixtures, cwd);
100+
await cpy(fixtures, cwd, {dot: true});
100101
const globbedAssets = await globAssets({cwd}, ['*.txt']);
101102

102103
t.deepEqual(sortAssets(globbedAssets), sortAssets(['upload_other.txt', 'upload.txt']));
103104
});
104105

105106
test('Accept glob array with one value', async (t) => {
106107
const cwd = tempy.directory();
107-
await copy(fixtures, cwd);
108+
await cpy(fixtures, cwd, {dot: true});
108109
const globbedAssets = await globAssets({cwd}, [['*load.txt'], ['*_other.txt']]);
109110

110111
t.deepEqual(sortAssets(globbedAssets), sortAssets(['upload_other.txt', 'upload.txt']));
111112
});
112113

113114
test('Include globs that resolve to no files as defined', async (t) => {
114115
const cwd = tempy.directory();
115-
await copy(fixtures, cwd);
116+
await cpy(fixtures, cwd, {dot: true});
116117
const globbedAssets = await globAssets({cwd}, [['upload.txt', '!upload.txt']]);
117118

118119
t.deepEqual(sortAssets(globbedAssets), sortAssets(['!upload.txt', 'upload.txt']));
119120
});
120121

121122
test('Accept glob array with one value for missing files', async (t) => {
122123
const cwd = tempy.directory();
123-
await copy(fixtures, cwd);
124+
await cpy(fixtures, cwd, {dot: true});
124125
const globbedAssets = await globAssets({cwd}, [['*missing.txt'], ['*_other.txt']]);
125126

126127
t.deepEqual(sortAssets(globbedAssets), sortAssets(['upload_other.txt', '*missing.txt']));
127128
});
128129

129130
test('Replace name by filename for Object that match multiple files', async (t) => {
130131
const cwd = tempy.directory();
131-
await copy(fixtures, cwd);
132+
await cpy(fixtures, cwd, {dot: true});
132133
const globbedAssets = await globAssets({cwd}, [{path: '*.txt', name: 'upload_name', label: 'Upload label'}]);
133134

134135
t.deepEqual(
@@ -142,56 +143,56 @@ test('Replace name by filename for Object that match multiple files', async (t)
142143

143144
test('Include dotfiles', async (t) => {
144145
const cwd = tempy.directory();
145-
await copy(fixtures, cwd);
146+
await cpy(fixtures, cwd, {dot: true});
146147
const globbedAssets = await globAssets({cwd}, ['.dot*']);
147148

148149
t.deepEqual(globbedAssets, ['.dotfile']);
149150
});
150151

151152
test('Ingnore single negated glob', async (t) => {
152153
const cwd = tempy.directory();
153-
await copy(fixtures, cwd);
154+
await cpy(fixtures, cwd, {dot: true});
154155
const globbedAssets = await globAssets({cwd}, ['!*.txt']);
155156

156157
t.deepEqual(globbedAssets, []);
157158
});
158159

159160
test('Ingnore single negated glob in Object', async (t) => {
160161
const cwd = tempy.directory();
161-
await copy(fixtures, cwd);
162+
await cpy(fixtures, cwd, {dot: true});
162163
const globbedAssets = await globAssets({cwd}, [{path: '!*.txt'}]);
163164

164165
t.deepEqual(globbedAssets, []);
165166
});
166167

167168
test('Accept negated globs', async (t) => {
168169
const cwd = tempy.directory();
169-
await copy(fixtures, cwd);
170+
await cpy(fixtures, cwd, {dot: true});
170171
const globbedAssets = await globAssets({cwd}, [['*.txt', '!**/*_other.txt']]);
171172

172173
t.deepEqual(globbedAssets, ['upload.txt']);
173174
});
174175

175176
test('Expand directories', async (t) => {
176177
const cwd = tempy.directory();
177-
await copy(fixtures, resolve(cwd, 'dir'));
178+
await cpy(fixtures, resolve(cwd, 'dir'), {dot: true});
178179
const globbedAssets = await globAssets({cwd}, [['dir']]);
179180

180181
t.deepEqual(sortAssets(globbedAssets), sortAssets(['dir', 'dir/upload_other.txt', 'dir/upload.txt', 'dir/.dotfile']));
181182
});
182183

183184
test('Include empty tempy.directory as defined', async (t) => {
184185
const cwd = tempy.directory();
185-
await copy(fixtures, cwd);
186-
await ensureDir(resolve(cwd, 'empty'));
186+
await cpy(fixtures, cwd, {dot: true});
187+
await mkdir(resolve(cwd, 'empty'), {recursive: true});
187188
const globbedAssets = await globAssets({cwd}, [['empty']]);
188189

189190
t.deepEqual(globbedAssets, ['empty']);
190191
});
191192

192193
test('Deduplicate resulting files path', async (t) => {
193194
const cwd = tempy.directory();
194-
await copy(fixtures, cwd);
195+
await cpy(fixtures, cwd, {dot: true});
195196
const globbedAssets = await globAssets({cwd}, ['./upload.txt', resolve(cwd, 'upload.txt'), 'upload.txt']);
196197

197198
t.is(globbedAssets.length, 1);

test/integration.test.js

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,33 @@
11
import {resolve} from 'node:path';
22
import {escape} from 'node:querystring';
3+
import {stat} from 'node:fs/promises';
34

45
import test from 'ava';
5-
import {stat} from 'fs-extra';
6-
import {cleanAll} from 'nock';
7-
import {stub} from 'sinon';
8-
import proxyquire from 'proxyquire';
9-
import clearModule from 'clear-module';
6+
import nock from 'nock';
7+
import sinon from 'sinon';
8+
import quibble from 'quibble';
109
import SemanticReleaseError from '@semantic-release/error';
1110

1211
import {authenticate, upload} from './helpers/mock-github.js';
13-
import rateLimit from './helpers/rate-limit.js';
12+
import * as RATE_LIMIT_MOCK from './helpers/rate-limit.js';
1413

1514
const cwd = 'test/fixtures/files';
16-
const client = proxyquire('../lib/get-client', {'./definitions/rate-limit': rateLimit});
17-
18-
test.beforeEach((t) => {
19-
// Clear npm cache to refresh the module state
20-
clearModule('..');
21-
t.context.m = proxyquire('..', {
22-
'./lib/verify': proxyquire('../lib/verify', {'./get-client': client}),
23-
'./lib/publish': proxyquire('../lib/publish', {'./get-client': client}),
24-
'./lib/success': proxyquire('../lib/success', {'./get-client': client}),
25-
'./lib/fail': proxyquire('../lib/fail', {'./get-client': client}),
26-
});
15+
16+
test.beforeEach(async (t) => {
17+
// Mock rate limit imported via lib/get-client.js
18+
await quibble.reset();
19+
await quibble.esm('../lib/definitions/rate-limit.js', RATE_LIMIT_MOCK);
20+
21+
t.context.m = await import('../index.js');
2722
// Stub the logger
28-
t.context.log = stub();
29-
t.context.error = stub();
23+
t.context.log = sinon.stub();
24+
t.context.error = sinon.stub();
3025
t.context.logger = {log: t.context.log, error: t.context.error};
3126
});
3227

3328
test.afterEach.always(() => {
3429
// Clear nock
35-
cleanAll();
30+
nock.cleanAll();
3631
});
3732

3833
test.serial('Verify GitHub auth', async (t) => {

test/publish.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
import {stat} from 'node:fs/promises';
12
import {resolve} from 'node:path';
23
import {escape} from 'node:querystring';
34

45
import test from 'ava';
5-
import {stat} from 'fs-extra';
66
import {cleanAll} from 'nock';
77
import {stub} from 'sinon';
88
import proxyquire from 'proxyquire';

0 commit comments

Comments
 (0)