Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -200,14 +200,16 @@ describe('getPackagesInTopologicalOrder', function () {
);
});

it('returns empty array when there are no workspaces', async function () {
it('supports single repo without workspace', async function () {
await fs.writeFile(
path.join(tmpDir, 'package.json'),
JSON.stringify({ name: 'root' }),
);

const result = await getPackagesInTopologicalOrder(tmpDir);
const names = result.map((p) => p.name);

assert.deepStrictEqual(result, []);
assert.strictEqual(names.length, 1);
assert.ok(names.includes('root'));
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@ export interface PackageInfo {
export async function getPackagesInTopologicalOrder(
monorepoRoot: string,
): Promise<PackageInfo[]> {
const patterns: string[] =
JSON.parse(
await fs.readFile(path.join(monorepoRoot, `package.json`), 'utf8'),
).workspaces || [];
const patterns: string[] = JSON.parse(
await fs.readFile(path.join(monorepoRoot, `package.json`), 'utf8'),
).workspaces || ['.']; // default value that considers monorepo root as a "workspace" for further analysis

const packageJsonPaths = await glob(
// NOTE: glob patterns should always use forward slashes,
Expand Down