Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: TS test fixes #436

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
3 changes: 3 additions & 0 deletions packages/plop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,13 @@
},
"devDependencies": {
"cli-testing-library": "^2.0.2",
"cross-env": "^7.0.3",
"glob": "^10.3.12",
"inquirer-directory": "^2.2.0",
"nyc": "^15.1.0",
"plop-pack-fancy-comments": "^0.2.1",
"queue-microtask": "^1.2.3",
"tsx": "^4.7.2",
"vitest": "^1.1.0"
},
"homepage": "https://plopjs.com",
Expand Down
1 change: 1 addition & 0 deletions packages/plop/src/plop.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env node

import "tsx";
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is currently necessary, there is something strange going on with the test runner where the normal NODE_* env vars are not getting through properly.

import ora from "ora";
import path from "node:path";
import Liftoff from "liftoff";
Expand Down
2 changes: 1 addition & 1 deletion packages/plop/tests/examples/typescript/plopfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module.exports = function (plop: NodePlopAPI) {
{
type: "input",
name: "name",
message: "What is your name?",
message: "What is your Typescript name?",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is to differentiate the plopfile.ts from the plopfile.js content.

validate: function (value) {
if (/.+/.test(value)) {
return true;
Expand Down
2 changes: 1 addition & 1 deletion packages/plop/tests/examples/typescript/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"strict": true,
"baseUrl": "./",
"paths": {
"plop": ["../../src/plop.d.ts"]
"plop": ["../../../src/plop.d.ts"]
}
}
}
6 changes: 5 additions & 1 deletion packages/plop/tests/examples/wrap-plop/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env node
import path from "node:path";
import { globSync } from "glob";
import minimist from "minimist";
import { Plop, run } from "../../../instrumented/src/plop.js";

Expand All @@ -13,8 +14,11 @@ Plop.prepare(
{
cwd: argv.cwd,
preload: argv.preload || [],
// Use the plopfile in cwd if available, otherwise use the default plopfile
// In order for `plop` to always pick up the `plopfile.js` despite the CWD, you must use `__dirname`
configPath: path.join(__dirname, "plopfile.cjs"),
configPath:
globSync(`plopfile.{cjs,js,ts}`, { cwd: argv.cwd, absolute: true })[0] ||
path.join(__dirname, "plopfile.cjs"),
completion: argv.completion,
// This will merge the `plop` argv and the generator argv.
// This means that you don't need to use `--` anymore
Expand Down
2 changes: 1 addition & 1 deletion packages/plop/tests/typescript.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ test("support typescript out of the box", async () => {
cwd: resolve(__dirname, "./examples/typescript"),
});

expect(await findByText("What is your name?")).toBeInTheConsole();
expect(await findByText("What is your Typescript name?")).toBeInTheConsole();
});
Loading
Loading