Skip to content

Commit 319fc7d

Browse files
committed
Formats files with prettier
1 parent b1ed206 commit 319fc7d

File tree

121 files changed

+4273
-3676
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

121 files changed

+4273
-3676
lines changed

packages/berry-cli/sources/WorkspaceRequiredError.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ export class WorkspaceRequiredError extends UsageError {
44
constructor(cwd: string) {
55
super(`This command can only be run from within a workspace of your project.`);
66
}
7-
}
7+
}

packages/berry-cli/sources/cli.ts

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
1-
import {Configuration} from '@berry/core';
2-
import {xfs, NodeFS} from '@berry/fslib';
3-
import {execFileSync} from 'child_process';
1+
import {Configuration} from '@berry/core';
2+
import {xfs, NodeFS} from '@berry/fslib';
3+
import {execFileSync} from 'child_process';
44
import {UsageError, Clipanion} from 'clipanion';
5-
import {posix} from 'path';
6-
import * as yup from 'yup';
5+
import {posix} from 'path';
6+
import * as yup from 'yup';
77

8-
import {pluginConfiguration} from './pluginConfiguration';
8+
import {pluginConfiguration} from './pluginConfiguration';
99

1010
const clipanion = new Clipanion({configKey: null});
1111

12-
clipanion.topLevel(`[--cwd PATH]`)
13-
.validate(yup.object().shape({
12+
clipanion.topLevel(`[--cwd PATH]`).validate(
13+
yup.object().shape({
1414
cwd: yup.string().transform((cwd = process.cwd()) => {
1515
// Note that the `--cwd` option might be a relative path that we need to resolve
1616
return posix.resolve(NodeFS.toPortablePath(process.cwd()), NodeFS.toPortablePath(cwd));
1717
}),
18-
}));
18+
}),
19+
);
1920

2021
function runBinary(path: string) {
2122
const physicalPath = NodeFS.fromPortablePath(path);
@@ -24,17 +25,17 @@ function runBinary(path: string) {
2425
execFileSync(process.execPath, [physicalPath, ...process.argv.slice(2)], {
2526
stdio: `inherit`,
2627
env: {
27-
... process.env,
28+
...process.env,
2829
YARN_IGNORE_PATH: `1`,
29-
}
30+
},
3031
});
3132
} else {
3233
execFileSync(physicalPath, process.argv.slice(2), {
3334
stdio: `inherit`,
3435
env: {
35-
... process.env,
36+
...process.env,
3637
YARN_IGNORE_PATH: `1`,
37-
}
38+
},
3839
});
3940
}
4041
}
@@ -47,7 +48,14 @@ async function run() {
4748

4849
if (yarnPath !== null && !ignorePath) {
4950
if (!xfs.existsSync(yarnPath)) {
50-
clipanion.error(new Error(`The "yarn-path" option has been set (in ${configuration.sources.get(`yarnPath`)}), but the specified location doesn't exist (${yarnPath}).`), {stream: process.stderr});
51+
clipanion.error(
52+
new Error(
53+
`The "yarn-path" option has been set (in ${configuration.sources.get(
54+
`yarnPath`,
55+
)}), but the specified location doesn't exist (${yarnPath}).`,
56+
),
57+
{stream: process.stderr},
58+
);
5159
process.exitCode = 1;
5260
} else {
5361
try {
@@ -58,11 +66,10 @@ async function run() {
5866
}
5967
} else {
6068
for (const plugin of configuration.plugins.values())
61-
for (const command of plugin.commands || [])
62-
command(clipanion, pluginConfiguration);
69+
for (const command of plugin.commands || []) command(clipanion, pluginConfiguration);
6370

6471
clipanion.runExit(`yarn`, process.argv.slice(2), {
65-
cwd: NodeFS.toPortablePath(process.cwd())
72+
cwd: NodeFS.toPortablePath(process.cwd()),
6673
});
6774
}
6875
}

packages/berry-cli/sources/pluginConfiguration.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {PluginConfiguration} from '@berry/core';
1+
import {PluginConfiguration} from '@berry/core';
22

33
// @ts-ignore
44
import embedPluginConfiguration from './pluginConfiguration.raw.js';

packages/berry-core/sources/AliasResolver.ts

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {Resolver, ResolveOptions, MinimalResolveOptions} from './Resolver';
2-
import * as structUtils from './structUtils';
3-
import {Descriptor, Locator} from './types';
2+
import * as structUtils from './structUtils';
3+
import {Descriptor, Locator} from './types';
44

55
export class AliasResolver implements Resolver {
66
private next: Resolver;
@@ -35,22 +35,18 @@ export class AliasResolver implements Resolver {
3535

3636
for (const descriptor of Array.from(pkg.dependencies.values())) {
3737
for (const {pattern, reference} of topLevelWorkspace.manifest.resolutions) {
38-
if (pattern.from && pattern.from.fullName !== structUtils.requirableIdent(locator))
39-
continue;
40-
if (pattern.from && pattern.from.description && pattern.from.description !== locator.reference)
41-
continue;
38+
if (pattern.from && pattern.from.fullName !== structUtils.requirableIdent(locator)) continue;
39+
if (pattern.from && pattern.from.description && pattern.from.description !== locator.reference) continue;
4240

43-
if (pattern.descriptor.fullName !== structUtils.requirableIdent(descriptor))
44-
continue;
45-
if (pattern.descriptor.description && pattern.descriptor.description !== descriptor.range)
46-
continue;
41+
if (pattern.descriptor.fullName !== structUtils.requirableIdent(descriptor)) continue;
42+
if (pattern.descriptor.description && pattern.descriptor.description !== descriptor.range) continue;
4743

4844
const alias = opts.resolver.bindDescriptor(
4945
structUtils.makeDescriptor(descriptor, reference),
5046
topLevelWorkspace.anchoredLocator,
5147
opts,
5248
);
53-
49+
5450
pkg.dependencies.delete(descriptor.identHash);
5551
pkg.dependencies.set(alias.identHash, alias);
5652
}

packages/berry-core/sources/Cache.ts

Lines changed: 35 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
import {FakeFS, LazyFS, NodeFS, ZipFS, xfs} from '@berry/fslib';
2-
import {lock, unlock} from 'lockfile';
3-
import {posix} from 'path';
4-
import {promisify} from 'util';
2+
import {lock, unlock} from 'lockfile';
3+
import {posix} from 'path';
4+
import {promisify} from 'util';
55

6-
import {Configuration} from './Configuration';
7-
import {MessageName, ReportError} from './Report';
8-
import * as hashUtils from './hashUtils';
9-
import * as structUtils from './structUtils';
10-
import {LocatorHash, Locator} from './types';
6+
import {Configuration} from './Configuration';
7+
import {MessageName, ReportError} from './Report';
8+
import * as hashUtils from './hashUtils';
9+
import * as structUtils from './structUtils';
10+
import {LocatorHash, Locator} from './types';
1111

1212
const lockP = promisify(lock);
1313
const unlockP = promisify(unlock);
1414

1515
export type FetchFromCacheOptions = {
16-
checksums: Map<LocatorHash, Locator>,
16+
checksums: Map<LocatorHash, Locator>;
1717
};
1818

1919
export class Cache {
@@ -50,7 +50,11 @@ export class Cache {
5050
});
5151
}
5252

53-
async fetchPackageFromCache(locator: Locator, expectedChecksum: string | null, loader?: () => Promise<ZipFS>): Promise<[FakeFS, () => void, string]> {
53+
async fetchPackageFromCache(
54+
locator: Locator,
55+
expectedChecksum: string | null,
56+
loader?: () => Promise<ZipFS>,
57+
): Promise<[FakeFS, () => void, string]> {
5458
const cachePath = this.getLocatorPath(locator);
5559
const baseFs = new NodeFS();
5660

@@ -66,9 +70,17 @@ export class Cache {
6670
return actualChecksum;
6771

6872
default:
69-
case `throw`: {
70-
throw new ReportError(MessageName.CACHE_CHECKSUM_MISMATCH, `${structUtils.prettyLocator(this.configuration, locator)} doesn't resolve to an archive that matches the expected checksum`);
71-
} break;
73+
case `throw`:
74+
{
75+
throw new ReportError(
76+
MessageName.CACHE_CHECKSUM_MISMATCH,
77+
`${structUtils.prettyLocator(
78+
this.configuration,
79+
locator,
80+
)} doesn't resolve to an archive that matches the expected checksum`,
81+
);
82+
}
83+
break;
7284
}
7385
}
7486

@@ -77,7 +89,9 @@ export class Cache {
7789

7890
const loadPackage = async () => {
7991
if (!loader)
80-
throw new Error(`Cache entry required but missing for ${structUtils.prettyLocator(this.configuration, locator)}`);
92+
throw new Error(
93+
`Cache entry required but missing for ${structUtils.prettyLocator(this.configuration, locator)}`,
94+
);
8195

8296
return await this.writeFileIntoCache(cachePath, async () => {
8397
const zipFs = await loader();
@@ -108,20 +122,20 @@ export class Cache {
108122
}
109123
};
110124

111-
for (let mutex; mutex = this.mutexes.get(locator.locatorHash);)
112-
await mutex;
125+
for (let mutex; (mutex = this.mutexes.get(locator.locatorHash)); ) await mutex;
113126

114-
const checksum = baseFs.existsSync(cachePath)
115-
? await validateFile(cachePath)
116-
: await loadPackageThroughMutex();
127+
const checksum = baseFs.existsSync(cachePath) ? await validateFile(cachePath) : await loadPackageThroughMutex();
117128

118129
let zipFs: ZipFS | null = null;
119130

120131
const lazyFs: LazyFS = new LazyFS(() => {
121132
try {
122-
return zipFs = new ZipFS(cachePath, {readOnly: true, baseFs});
133+
return (zipFs = new ZipFS(cachePath, {readOnly: true, baseFs}));
123134
} catch (error) {
124-
error.message = `Failed to open the cache entry for ${structUtils.prettyLocator(this.configuration, locator)}: ${error.message}`;
135+
error.message = `Failed to open the cache entry for ${structUtils.prettyLocator(
136+
this.configuration,
137+
locator,
138+
)}: ${error.message}`;
125139
throw error;
126140
}
127141
});

0 commit comments

Comments
 (0)