Skip to content

Commit e2be210

Browse files
authored
build: update prettier to 3.4.2 (#311)
1 parent 6ae35e3 commit e2be210

8 files changed

+24
-29
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"jest": "jest --coverage",
1818
"lint": "npm run prettier && npm run eslint",
1919
"prettier": "prettier --check \"src/**/*.ts\" \"test/**/*.ts\"",
20+
"prettier:write": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
2021
"prepublishOnly": "npm run build",
2122
"test": "npm run lint && npm run jest",
2223
"test:nonetwork": "npm run lint && npm run jest -- --testPathIgnorePatterns network.spec"
@@ -53,7 +54,7 @@
5354
"husky": "^2.3.0",
5455
"jest": "^29.3.1",
5556
"lint-staged": "^13.0.4",
56-
"prettier": "^1.17.1",
57+
"prettier": "^3.4.2",
5758
"ts-jest": "^29.0.0",
5859
"typedoc": "~0.24.8",
5960
"typescript": "^4.9.3"

src/Cache.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,7 @@ export class Cache {
2020
const { search, hash, pathname, ...rest } = parsedDownloadUrl;
2121
const strippedUrl = url.format({ ...rest, pathname: path.dirname(pathname || 'electron') });
2222

23-
return crypto
24-
.createHash('sha256')
25-
.update(strippedUrl)
26-
.digest('hex');
23+
return crypto.createHash('sha256').update(strippedUrl).digest('hex');
2724
}
2825

2926
public getCachePath(downloadUrl: string, fileName: string): string {

src/GotDownloader.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const PROGRESS_BAR_DELAY_IN_SECONDS = 30;
1313
* @category Downloader
1414
* @see {@link https://github.com/sindresorhus/got/tree/v11.8.5?tab=readme-ov-file#options | `got#options`} for possible keys/values.
1515
*/
16-
export type GotDownloaderOptions = (GotOptions) & { isStream?: true } & {
16+
export type GotDownloaderOptions = GotOptions & { isStream?: true } & {
1717
/**
1818
* if defined, triggers every time `got`'s
1919
* {@link https://github.com/sindresorhus/got/tree/v11.8.5?tab=readme-ov-file#downloadprogress | `downloadProgress``} event callback is triggered.
@@ -66,7 +66,7 @@ export class GotDownloader implements Downloader<GotDownloaderOptions> {
6666
}
6767
await new Promise<void>((resolve, reject) => {
6868
const downloadStream = got.stream(url, gotOptions);
69-
downloadStream.on('downloadProgress', async progress => {
69+
downloadStream.on('downloadProgress', async (progress) => {
7070
progressPercent = progress.percent;
7171
if (bar) {
7272
bar.update(progress.percent);
@@ -75,7 +75,7 @@ export class GotDownloader implements Downloader<GotDownloaderOptions> {
7575
await getProgressCallback(progress);
7676
}
7777
});
78-
downloadStream.on('error', error => {
78+
downloadStream.on('error', (error) => {
7979
if (error instanceof HTTPError && error.response.statusCode === 404) {
8080
error.message += ` for ${error.response.url}`;
8181
}
@@ -85,7 +85,7 @@ export class GotDownloader implements Downloader<GotDownloaderOptions> {
8585

8686
reject(error);
8787
});
88-
writeStream.on('error', error => reject(error));
88+
writeStream.on('error', (error) => reject(error));
8989
writeStream.on('close', () => resolve());
9090

9191
downloadStream.pipe(writeStream);

src/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ async function validateArtifact(
5050
): Promise<void> {
5151
return await withTempDirectoryIn(
5252
artifactDetails.tempDirectory,
53-
async tempFolder => {
53+
async (tempFolder) => {
5454
// Don't try to verify the hash of the hash file itself
5555
// and for older versions that don't have a SHASUMS256.txt
5656
if (
@@ -69,7 +69,7 @@ async function validateArtifact(
6969
);
7070
}
7171
const generatedChecksums = fileNames
72-
.map(fileName => `${checksums[fileName]} *${fileName}`)
72+
.map((fileName) => `${checksums[fileName]} *${fileName}`)
7373
.join('\n');
7474
await fs.writeFile(shasumPath, generatedChecksums);
7575
} else {
@@ -205,7 +205,7 @@ export async function downloadArtifact(
205205

206206
return await withTempDirectoryIn(
207207
details.tempDirectory,
208-
async tempFolder => {
208+
async (tempFolder) => {
209209
const tempDownloadPath = path.resolve(tempFolder, getArtifactFileName(details));
210210

211211
const downloader = details.downloader || (await getDownloaderForSystem());

src/utils.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,7 @@ export function normalizeVersion(version: string): string {
6262
* Runs the `uname` command and returns the trimmed output.
6363
*/
6464
export function uname(): string {
65-
return childProcess
66-
.execSync('uname -m')
67-
.toString()
68-
.trim();
65+
return childProcess.execSync('uname -m').toString().trim();
6966
}
7067

7168
/**

test/GotDownloader.network.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ describe('GotDownloader', () => {
1010
it('should download a remote file to the given file path', async () => {
1111
const downloader = new GotDownloader();
1212
let progressCallbackCalled = false;
13-
await withTempDirectory(async dir => {
13+
await withTempDirectory(async (dir) => {
1414
const testFile = path.resolve(dir, 'test.txt');
1515
expect(await fs.pathExists(testFile)).toEqual(false);
1616
await downloader.download(
@@ -29,9 +29,9 @@ describe('GotDownloader', () => {
2929
}, TempDirCleanUpMode.CLEAN);
3030
});
3131

32-
it('should throw an error if the file does not exist', async function() {
32+
it('should throw an error if the file does not exist', async function () {
3333
const downloader = new GotDownloader();
34-
await withTempDirectory(async dir => {
34+
await withTempDirectory(async (dir) => {
3535
const testFile = path.resolve(dir, 'test.txt');
3636
const url = 'https://github.com/electron/electron/releases/download/v2.0.18/bad.file';
3737
const snapshot = `[HTTPError: Response code 404 (Not Found) for ${url}]`;
@@ -47,7 +47,7 @@ describe('GotDownloader', () => {
4747
setTimeout(() => emitter.emit('error', 'bad write error thing'), 10);
4848
return emitter as fs.WriteStream;
4949
});
50-
await withTempDirectory(async dir => {
50+
await withTempDirectory(async (dir) => {
5151
const testFile = path.resolve(dir, 'test.txt');
5252
await expect(
5353
downloader.download(
@@ -60,7 +60,7 @@ describe('GotDownloader', () => {
6060

6161
it('should download to a deep uncreated path', async () => {
6262
const downloader = new GotDownloader();
63-
await withTempDirectory(async dir => {
63+
await withTempDirectory(async (dir) => {
6464
const testFile = path.resolve(dir, 'f', 'b', 'test.txt');
6565
expect(await fs.pathExists(testFile)).toEqual(false);
6666
await expect(

test/utils.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ describe('utils', () => {
3737

3838
describe('withTempDirectory()', () => {
3939
it('should generate a new and empty directory', async () => {
40-
await withTempDirectory(async dir => {
40+
await withTempDirectory(async (dir) => {
4141
expect(await fs.pathExists(dir)).toEqual(true);
4242
expect(await fs.readdir(dir)).toEqual([]);
4343
}, TempDirCleanUpMode.CLEAN);
@@ -48,7 +48,7 @@ describe('utils', () => {
4848
});
4949

5050
it('should delete the directory when the function terminates', async () => {
51-
const mDir = await withTempDirectory(async dir => {
51+
const mDir = await withTempDirectory(async (dir) => {
5252
return dir;
5353
}, TempDirCleanUpMode.CLEAN);
5454
expect(mDir).not.toBeUndefined();
@@ -58,7 +58,7 @@ describe('utils', () => {
5858
it('should delete the directory and reject correctly even if the function throws', async () => {
5959
let mDir: string | undefined;
6060
await expect(
61-
withTempDirectory(async dir => {
61+
withTempDirectory(async (dir) => {
6262
mDir = dir;
6363
throw 'my error';
6464
}, TempDirCleanUpMode.CLEAN),
@@ -69,7 +69,7 @@ describe('utils', () => {
6969
});
7070

7171
it('should not delete the directory if told to orphan the temp dir', async () => {
72-
const mDir = await withTempDirectory(async dir => {
72+
const mDir = await withTempDirectory(async (dir) => {
7373
return dir;
7474
}, TempDirCleanUpMode.ORPHAN);
7575
expect(mDir).not.toBeUndefined();

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3445,10 +3445,10 @@ prelude-ls@~1.1.2:
34453445
resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54"
34463446
integrity sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=
34473447

3448-
prettier@^1.17.1:
3449-
version "1.17.1"
3450-
resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.17.1.tgz#ed64b4e93e370cb8a25b9ef7fef3e4fd1c0995db"
3451-
integrity sha512-TzGRNvuUSmPgwivDqkZ9tM/qTGW9hqDKWOE9YHiyQdixlKbv7kvEqsmDPrcHJTKwthU774TQwZXVtaQ/mMsvjg==
3448+
prettier@^3.4.2:
3449+
version "3.4.2"
3450+
resolved "https://registry.yarnpkg.com/prettier/-/prettier-3.4.2.tgz#a5ce1fb522a588bf2b78ca44c6e6fe5aa5a2b13f"
3451+
integrity sha512-e9MewbtFo+Fevyuxn/4rrcDAaq0IYxPGLvObpQjiZBMAzB9IGmzlnG9RZy3FFas+eBMu2vA0CszMeduow5dIuQ==
34523452

34533453
pretty-format@^29.0.0, pretty-format@^29.3.1:
34543454
version "29.3.1"

0 commit comments

Comments
 (0)