Skip to content
Open
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
15 changes: 14 additions & 1 deletion src/domains/models/SpecificationFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,16 @@ export class Specification {
fileURL: targetUrl,
});
}
}

static async fromStdin(): Promise<Specification> {
let spec = '';
process.stdin.setEncoding('utf8');
for await (const chunk of process.stdin) {
spec += chunk;
}
return new Specification(spec);
}


export default class SpecificationFile {
private readonly pathToFile: string;
Expand Down Expand Up @@ -166,6 +175,10 @@ export async function load(
// NOSONAR
try {
if (filePathOrContextName) {
// Handle stdin input
if (filePathOrContextName === '-') {
return Specification.fromStdin();
}
if (loadType?.file) {
return Specification.fromFile(filePathOrContextName);
}
Expand Down
Loading