2018-05-10 01:27:41 +01:00
|
|
|
describe("loads --plugin by its relative path", () => {
|
2023-04-11 08:44:23 +08:00
|
|
|
runCli("plugins", [
|
2018-05-10 01:27:41 +01:00
|
|
|
"automatic/file.txt",
|
|
|
|
|
"--parser=bar",
|
|
|
|
|
"--plugin=./automatic/node_modules/prettier-plugin-bar/index.js",
|
|
|
|
|
]).test({
|
2023-03-30 14:25:28 +08:00
|
|
|
stdout: "content from `prettier-plugin-bar` package + contents",
|
2018-05-10 01:27:41 +01:00
|
|
|
stderr: "",
|
|
|
|
|
status: 0,
|
|
|
|
|
write: [],
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe("loads --plugin by its relative path without leading ./", () => {
|
2023-04-11 08:44:23 +08:00
|
|
|
runCli("plugins", [
|
2018-05-10 01:27:41 +01:00
|
|
|
"automatic/file.txt",
|
|
|
|
|
"--parser=bar",
|
|
|
|
|
"--plugin=automatic/node_modules/prettier-plugin-bar/index.js",
|
|
|
|
|
]).test({
|
2023-03-30 14:25:28 +08:00
|
|
|
stdout: "content from `prettier-plugin-bar` package + contents",
|
2018-05-10 01:27:41 +01:00
|
|
|
stderr: "",
|
|
|
|
|
status: 0,
|
|
|
|
|
write: [],
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2022-08-01 10:48:37 +08:00
|
|
|
describe("loads --plugin by package name", () => {
|
2023-04-11 08:44:23 +08:00
|
|
|
runCli("plugins/automatic", [
|
2022-08-01 10:48:37 +08:00
|
|
|
"file.txt",
|
|
|
|
|
"--parser=foobar",
|
|
|
|
|
"--plugin=@user/prettier-plugin-foobar",
|
|
|
|
|
]).test({
|
2023-03-30 14:25:28 +08:00
|
|
|
stdout: "foobar+contents",
|
2022-08-01 10:48:37 +08:00
|
|
|
stderr: "",
|
|
|
|
|
status: 0,
|
|
|
|
|
write: [],
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2022-08-06 10:42:27 +08:00
|
|
|
describe("loads --plugin by filename without leading ./, should resolve to file, not package", () => {
|
2023-04-11 08:44:23 +08:00
|
|
|
runCli("plugins/automatic", [
|
2020-02-18 22:36:17 +08:00
|
|
|
"file.txt",
|
2022-08-06 10:42:27 +08:00
|
|
|
"--parser=baz",
|
|
|
|
|
"--plugin=prettier-plugin-baz.js",
|
2020-02-18 22:36:17 +08:00
|
|
|
]).test({
|
2023-03-30 14:25:28 +08:00
|
|
|
stdout: "content from `prettier-plugin-baz.js` file + contents",
|
2018-05-10 01:27:41 +01:00
|
|
|
stderr: "",
|
|
|
|
|
status: 0,
|
|
|
|
|
write: [],
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe("loads --plugin by bespoke plugin name (assuming it is installed in cwd)", () => {
|
2023-04-11 08:44:23 +08:00
|
|
|
runCli("plugins/bespoke", [
|
2018-05-10 01:27:41 +01:00
|
|
|
"../automatic/file.txt",
|
|
|
|
|
"--parser=bespoke",
|
2022-08-06 10:42:27 +08:00
|
|
|
"--plugin=@company/prettier-plugin-bespoke/main.js",
|
2018-05-10 01:27:41 +01:00
|
|
|
]).test({
|
2023-03-30 14:25:28 +08:00
|
|
|
stdout: "bespoke+contents",
|
2018-05-10 01:27:41 +01:00
|
|
|
stderr: "",
|
|
|
|
|
status: 0,
|
|
|
|
|
write: [],
|
|
|
|
|
});
|
|
|
|
|
});
|
2023-12-13 16:16:15 +08:00
|
|
|
|
|
|
|
|
describe.only("support absolute path in config file", () => {
|
|
|
|
|
runCli("cli/config/plugins/absolute-path", ["--parser=uppercase-rocks"], {
|
|
|
|
|
input: "prettier should be uppercase",
|
|
|
|
|
}).test({
|
|
|
|
|
stdout: "PRETTIER SHOULD BE UPPERCASE",
|
|
|
|
|
stderr: "",
|
|
|
|
|
status: 0,
|
|
|
|
|
write: [],
|
|
|
|
|
});
|
|
|
|
|
});
|