Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: update prettier to 3.4.2 #311

Merged
merged 1 commit into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"jest": "jest --coverage",
"lint": "npm run prettier && npm run eslint",
"prettier": "prettier --check \"src/**/*.ts\" \"test/**/*.ts\"",
"prettier:write": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
"prepublishOnly": "npm run build",
"test": "npm run lint && npm run jest",
"test:nonetwork": "npm run lint && npm run jest -- --testPathIgnorePatterns network.spec"
Expand Down Expand Up @@ -53,7 +54,7 @@
"husky": "^2.3.0",
"jest": "^29.3.1",
"lint-staged": "^13.0.4",
"prettier": "^1.17.1",
"prettier": "^3.4.2",
"ts-jest": "^29.0.0",
"typedoc": "~0.24.8",
"typescript": "^4.9.3"
Expand Down
5 changes: 1 addition & 4 deletions src/Cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@ export class Cache {
const { search, hash, pathname, ...rest } = parsedDownloadUrl;
const strippedUrl = url.format({ ...rest, pathname: path.dirname(pathname || 'electron') });

return crypto
.createHash('sha256')
.update(strippedUrl)
.digest('hex');
return crypto.createHash('sha256').update(strippedUrl).digest('hex');
}

public getCachePath(downloadUrl: string, fileName: string): string {
Expand Down
8 changes: 4 additions & 4 deletions src/GotDownloader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const PROGRESS_BAR_DELAY_IN_SECONDS = 30;
* @category Downloader
* @see {@link https://github.com/sindresorhus/got/tree/v11.8.5?tab=readme-ov-file#options | `got#options`} for possible keys/values.
*/
export type GotDownloaderOptions = (GotOptions) & { isStream?: true } & {
export type GotDownloaderOptions = GotOptions & { isStream?: true } & {
/**
* if defined, triggers every time `got`'s
* {@link https://github.com/sindresorhus/got/tree/v11.8.5?tab=readme-ov-file#downloadprogress | `downloadProgress``} event callback is triggered.
Expand Down Expand Up @@ -66,7 +66,7 @@ export class GotDownloader implements Downloader<GotDownloaderOptions> {
}
await new Promise<void>((resolve, reject) => {
const downloadStream = got.stream(url, gotOptions);
downloadStream.on('downloadProgress', async progress => {
downloadStream.on('downloadProgress', async (progress) => {
progressPercent = progress.percent;
if (bar) {
bar.update(progress.percent);
Expand All @@ -75,7 +75,7 @@ export class GotDownloader implements Downloader<GotDownloaderOptions> {
await getProgressCallback(progress);
}
});
downloadStream.on('error', error => {
downloadStream.on('error', (error) => {
if (error instanceof HTTPError && error.response.statusCode === 404) {
error.message += ` for ${error.response.url}`;
}
Expand All @@ -85,7 +85,7 @@ export class GotDownloader implements Downloader<GotDownloaderOptions> {

reject(error);
});
writeStream.on('error', error => reject(error));
writeStream.on('error', (error) => reject(error));
writeStream.on('close', () => resolve());

downloadStream.pipe(writeStream);
Expand Down
6 changes: 3 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ async function validateArtifact(
): Promise<void> {
return await withTempDirectoryIn(
artifactDetails.tempDirectory,
async tempFolder => {
async (tempFolder) => {
// Don't try to verify the hash of the hash file itself
// and for older versions that don't have a SHASUMS256.txt
if (
Expand All @@ -69,7 +69,7 @@ async function validateArtifact(
);
}
const generatedChecksums = fileNames
.map(fileName => `${checksums[fileName]} *${fileName}`)
.map((fileName) => `${checksums[fileName]} *${fileName}`)
.join('\n');
await fs.writeFile(shasumPath, generatedChecksums);
} else {
Expand Down Expand Up @@ -205,7 +205,7 @@ export async function downloadArtifact(

return await withTempDirectoryIn(
details.tempDirectory,
async tempFolder => {
async (tempFolder) => {
const tempDownloadPath = path.resolve(tempFolder, getArtifactFileName(details));

const downloader = details.downloader || (await getDownloaderForSystem());
Expand Down
5 changes: 1 addition & 4 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,7 @@ export function normalizeVersion(version: string): string {
* Runs the `uname` command and returns the trimmed output.
*/
export function uname(): string {
return childProcess
.execSync('uname -m')
.toString()
.trim();
return childProcess.execSync('uname -m').toString().trim();
}

/**
Expand Down
10 changes: 5 additions & 5 deletions test/GotDownloader.network.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe('GotDownloader', () => {
it('should download a remote file to the given file path', async () => {
const downloader = new GotDownloader();
let progressCallbackCalled = false;
await withTempDirectory(async dir => {
await withTempDirectory(async (dir) => {
const testFile = path.resolve(dir, 'test.txt');
expect(await fs.pathExists(testFile)).toEqual(false);
await downloader.download(
Expand All @@ -29,9 +29,9 @@ describe('GotDownloader', () => {
}, TempDirCleanUpMode.CLEAN);
});

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

it('should download to a deep uncreated path', async () => {
const downloader = new GotDownloader();
await withTempDirectory(async dir => {
await withTempDirectory(async (dir) => {
const testFile = path.resolve(dir, 'f', 'b', 'test.txt');
expect(await fs.pathExists(testFile)).toEqual(false);
await expect(
Expand Down
8 changes: 4 additions & 4 deletions test/utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe('utils', () => {

describe('withTempDirectory()', () => {
it('should generate a new and empty directory', async () => {
await withTempDirectory(async dir => {
await withTempDirectory(async (dir) => {
expect(await fs.pathExists(dir)).toEqual(true);
expect(await fs.readdir(dir)).toEqual([]);
}, TempDirCleanUpMode.CLEAN);
Expand All @@ -48,7 +48,7 @@ describe('utils', () => {
});

it('should delete the directory when the function terminates', async () => {
const mDir = await withTempDirectory(async dir => {
const mDir = await withTempDirectory(async (dir) => {
return dir;
}, TempDirCleanUpMode.CLEAN);
expect(mDir).not.toBeUndefined();
Expand All @@ -58,7 +58,7 @@ describe('utils', () => {
it('should delete the directory and reject correctly even if the function throws', async () => {
let mDir: string | undefined;
await expect(
withTempDirectory(async dir => {
withTempDirectory(async (dir) => {
mDir = dir;
throw 'my error';
}, TempDirCleanUpMode.CLEAN),
Expand All @@ -69,7 +69,7 @@ describe('utils', () => {
});

it('should not delete the directory if told to orphan the temp dir', async () => {
const mDir = await withTempDirectory(async dir => {
const mDir = await withTempDirectory(async (dir) => {
return dir;
}, TempDirCleanUpMode.ORPHAN);
expect(mDir).not.toBeUndefined();
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3445,10 +3445,10 @@ prelude-ls@~1.1.2:
resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54"
integrity sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=

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

pretty-format@^29.0.0, pretty-format@^29.3.1:
version "29.3.1"
Expand Down
Loading