pwtg
Advanced tools
Comparing version 0.0.2 to 0.1.0
@@ -6,4 +6,6 @@ export default class PictGenerator { | ||
constructor(filepathModel: string, pictBinaryLocation: string); | ||
generate(output: "json" | "text", save?: boolean, saveLocation?: string): Promise<void>; | ||
generate(output: "json" | "text", save?: boolean, saveLocation?: string, seedLocation?: string): Promise<void>; | ||
private _prepArgs; | ||
private _resolveToFullpath; | ||
} | ||
//# sourceMappingURL=pict.d.ts.map |
@@ -13,23 +13,15 @@ import { promisify } from "node:util"; | ||
constructor(filepathModel, pictBinaryLocation) { | ||
this.filepathModel = resolve(process.cwd(), sParser.parse(filepathModel)); | ||
this.pictLocation = resolve(process.cwd(), sParser.parse(pictBinaryLocation)); | ||
this.filepathModel = this._resolveToFullpath(filepathModel); | ||
this.pictLocation = this._resolveToFullpath(pictBinaryLocation); | ||
this.generated = undefined; | ||
} | ||
async generate(output, save, saveLocation) { | ||
if (output == "json") { | ||
const { stdout } = await exFile(this.pictLocation, [ | ||
this.filepathModel, | ||
"-f:json", | ||
]); | ||
this.generated = sParser.parse(stdout); | ||
} | ||
else { | ||
const { stdout } = await exFile(this.pictLocation, [ | ||
this.filepathModel, | ||
"-f:text", | ||
]); | ||
this.generated = sParser.parse(stdout); | ||
} | ||
async generate(output, save, saveLocation, seedLocation) { | ||
const args = this._prepArgs(output, seedLocation); | ||
const { stdout } = await exFile(this.pictLocation, [ | ||
this.filepathModel, | ||
...args, | ||
]); | ||
this.generated = sParser.parse(stdout); | ||
if (save == true && typeof saveLocation === "string") { | ||
const sLoc = resolve(process.cwd(), sParser.parse(saveLocation)); | ||
const sLoc = this._resolveToFullpath(saveLocation); | ||
if (output == "json") { | ||
@@ -43,3 +35,22 @@ await writeJson(this.generated, sLoc); | ||
} | ||
_prepArgs(outputType, seedLocation) { | ||
const input = [ | ||
sParser.parse(outputType), | ||
sParser.optional().parse(seedLocation), | ||
]; | ||
const output = []; | ||
for (let i = 0; i < input.length; i++) { | ||
if (i === 0) { | ||
output.push(input[i] === "json" ? "-f:json" : "-f:text"); | ||
} | ||
else if (i === 1 && typeof input[i] !== "undefined") { | ||
output.push(`-e:${this._resolveToFullpath(input[i])}`); | ||
} | ||
} | ||
return output; | ||
} | ||
_resolveToFullpath(subpath) { | ||
return resolve(process.cwd(), sParser.parse(subpath)); | ||
} | ||
} | ||
//# sourceMappingURL=pict.js.map |
{ | ||
"name": "pwtg", | ||
"version": "0.0.2", | ||
"version": "0.1.0", | ||
"description": "Node.js Typescript wrapper for using Microsoft PICT programmatically.", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -61,1 +61,21 @@ # PWTG - PairWise Test Generator | ||
``` | ||
### Generate output using seed file | ||
What is seeding and when to use it - see [HERE](https://github.com/microsoft/pict/blob/main/doc/pict.md#seeding) | ||
```ts | ||
import PictGenerator from "pwtg"; | ||
const generator = new Generator( | ||
"path/to/input-model-file.txt", | ||
"path/to/pict/binary", | ||
); | ||
await generator.generate( | ||
"text", | ||
true, | ||
"file/path/to/output-text-file.txt", | ||
"path/to/seed-text-file.txt", | ||
); | ||
``` |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
13843
128
81