Skip to content

Commit 53f5a68

Browse files
committed
refactor: remove adapter function wrappers from Effect gen functions
1 parent 8887ccd commit 53f5a68

File tree

5 files changed

+21
-23
lines changed

5 files changed

+21
-23
lines changed

src/bun-package-manager.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,13 @@ import { InstallPackageError, PackageManager } from "./package-manager";
66
export const bunPackageManager = (bunPath = "bun") =>
77
PackageManager.of({
88
installPackage: ({ pkg, cwd }) =>
9-
Effect.gen(function* (_) {
9+
Effect.gen(function* () {
1010
// Run `bun add <pkg> --verbose`.
1111
// See https://bun.sh/docs/cli/add.
12-
const { stdout } = yield* _(
13-
Effect.tryPromise({
14-
try: () => execa(bunPath, ["add", pkg, "--verbose"], { cwd }),
15-
catch: (e) => new InstallPackageError({ cause: e }),
16-
}),
17-
);
12+
const { stdout } = yield* Effect.tryPromise({
13+
try: () => execa(bunPath, ["add", pkg, "--verbose"], { cwd }),
14+
catch: (e) => new InstallPackageError({ cause: e }),
15+
});
1816

1917
// With verbose output on, bun prints one line per installed package
2018
// (e.g., "[email protected]"), including all installed dependencies.

src/extract-package-api-effect.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,19 @@ export const extractPackageApiEffect = ({
1717
subpath = ".",
1818
maxDepth = 5,
1919
}: Omit<ExtractPackageApiOptions, "bunPath">) =>
20-
Effect.gen(function* (_) {
20+
Effect.gen(function* () {
2121
const startTime = performance.now();
22-
const pkgName = yield* _(packageName(pkg));
23-
const { path: cwd } = yield* _(workDir);
24-
const pm = yield* _(PackageManager);
25-
const packages = yield* _(pm.installPackage({ pkg, cwd }));
22+
const pkgName = yield* packageName(pkg);
23+
const { path: cwd } = yield* workDir;
24+
const pm = yield* PackageManager;
25+
const packages = yield* pm.installPackage({ pkg, cwd });
2626
const pkgDir = join(cwd, "node_modules", pkgName);
27-
const pkgJson = yield* _(packageJson(pkgDir));
28-
const types = yield* _(packageTypes(pkgJson, subpath));
27+
const pkgJson = yield* packageJson(pkgDir);
28+
const types = yield* packageTypes(pkgJson, subpath);
2929
const indexFilePath = join(pkgDir, types);
30-
const { project, indexFile } = yield* _(createProject({ indexFilePath, cwd }));
30+
const { project, indexFile } = yield* createProject({ indexFilePath, cwd });
3131
const overview = packageOverview(indexFile);
32-
const declarations = yield* _(packageDeclarations({ pkgName, project, indexFile, maxDepth }));
32+
const declarations = yield* packageDeclarations({ pkgName, project, indexFile, maxDepth });
3333
const pkgApi: PackageApi = {
3434
name: pkgJson.name,
3535
version: pkgJson.version,

src/package-name.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ export class PackageNameError extends Data.TaggedError("PackageNameError")<{
99

1010
/** @internal */
1111
export const packageName = (pkg: string) =>
12-
Effect.gen(function* (_) {
12+
Effect.gen(function* () {
1313
const versionMarker = pkg.lastIndexOf("@");
1414
const pkgName = pkg.slice(0, versionMarker > 0 ? versionMarker : undefined);
1515
const { validForNewPackages, warnings, errors } = validate(pkgName);
1616
if (!validForNewPackages) {
17-
return yield* _(new PackageNameError({ warnings, errors }));
17+
return yield* new PackageNameError({ warnings, errors });
1818
}
1919
return pkgName;
2020
});

src/package-types.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ export class PackageTypesError extends Data.TaggedError("PackageTypesError") {}
1414
@internal
1515
*/
1616
export const packageTypes = (pkgJson: Partial<NormalizedPackageJson>, subpath: string) =>
17-
Effect.gen(function* (_) {
18-
const resolvedPaths = yield* _(resolveExports(pkgJson, subpath));
17+
Effect.gen(function* () {
18+
const resolvedPaths = yield* resolveExports(pkgJson, subpath);
1919
const firstPath = resolvedPaths[0];
2020
if (firstPath && isTypesFile(firstPath)) {
2121
return firstPath;
@@ -27,7 +27,7 @@ export const packageTypes = (pkgJson: Partial<NormalizedPackageJson>, subpath: s
2727
if (isRootSubpath && pkgJson.typings && isTypesFile(pkgJson.typings)) {
2828
return pkgJson.typings;
2929
}
30-
return yield* _(new PackageTypesError());
30+
return yield* new PackageTypesError();
3131
});
3232

3333
const resolveExports = (pkgJson: Partial<NormalizedPackageJson>, subpath: string) => {

src/work-dir.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import { workDir } from "./work-dir";
77

88
const _workDir = () =>
99
Effect.runPromise(
10-
Effect.gen(function* (_) {
11-
const { path } = yield* _(workDir);
10+
Effect.gen(function* () {
11+
const { path } = yield* workDir;
1212
return path;
1313
}).pipe(Effect.scoped),
1414
);

0 commit comments

Comments
 (0)