Skip to content

Commit e72fa00

Browse files
committed
Output the [ackage's directory alongside its name
1 parent 6dc82ab commit e72fa00

File tree

3 files changed

+20
-7
lines changed

3 files changed

+20
-7
lines changed

.github/actions/info/dist.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ async function findPackages(directory, maxDepth) {
1414
if (item.name === "package.json") {
1515
try {
1616
const { default: { name } } = await import(fullPath, { with: { type: "json" } });
17-
if (name) yield name;
17+
if (name) {
18+
yield { name, directory };
19+
return;
20+
}
21+
;
1822
} catch {
1923
}
2024
}
@@ -56,7 +60,7 @@ async function main() {
5660
const packages = await findPackages(dirPath);
5761
core.setOutput(packageType, packages);
5862
core.summary.addHeading(`Found ${packageType}`);
59-
core.summary.addList(packages);
63+
core.summary.addList(packages.map(({ name }) => name));
6064
core.summary.write();
6165
}
6266
try {

.github/actions/info/index.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,17 @@ import pathlib from 'path';
33
import * as core from '@actions/core';
44
import { getExecOutput } from '@actions/exec';
55

6+
interface PackageRecord {
7+
directory: string
8+
name: string
9+
}
10+
611
/**
712
* Recursively locates the packages present in a directory, up to an optional max depth
813
*/
914
async function findPackages(directory: string, maxDepth?: number) {
10-
const output: string[] = [];
11-
async function* recurser(currentDir: string, currentDepth: number): AsyncGenerator<string> {
15+
const output: PackageRecord[] = [];
16+
async function* recurser(currentDir: string, currentDepth: number): AsyncGenerator<PackageRecord> {
1217
if (maxDepth !== undefined && currentDepth >= maxDepth) return;
1318

1419
const items = await fs.readdir(currentDir, { withFileTypes: true });
@@ -18,7 +23,10 @@ async function findPackages(directory: string, maxDepth?: number) {
1823
if (item.name === 'package.json') {
1924
try {
2025
const { default: { name } } = await import(fullPath, { with: { type: 'json' }});
21-
if (name) yield name;
26+
if (name) {
27+
yield { name, directory };
28+
return;
29+
};
2230
} catch {}
2331
}
2432
continue;
@@ -66,7 +74,7 @@ async function main() {
6674
const packages = await findPackages(dirPath);
6775
core.setOutput(packageType, packages);
6876
core.summary.addHeading(`Found ${packageType}`);
69-
core.summary.addList(packages);
77+
core.summary.addList(packages.map(({ name }) => name));
7078
core.summary.write();
7179
}
7280

.github/workflows/new-workflow.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,11 @@ jobs:
6565
cache: yarn
6666

6767
- name: Install dependencies
68-
run: yarn workspaces focus ${{ matrix.package }}
68+
run: yarn workspaces focus ${{ matrix.package.name }}
6969

7070
- name: tsc and test
7171
run: |
72+
cd ${{ matrix.package.directory }}
7273
yarn tsc
7374
yarn test
7475

0 commit comments

Comments
 (0)