Skip to content

Commit fe9f781

Browse files
committed
fix(core): set default cmd and ignore files prefix with _
1 parent 49e2569 commit fe9f781

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

packages/core/__tests__/loader.spec.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ jest.mock("../src/middleware");
1212

1313
describe("LESY:Loader", () => {
1414
describe.each(["js", "ts"])("test %s", (flavor: string) => {
15-
let p;
16-
let d;
15+
let p: Function;
16+
let d: Function;
1717
let loader: LesyLoader;
1818
const addCmdRawObjSpy = jest.fn();
1919
const featAddSpy = jest.fn();
@@ -69,6 +69,11 @@ describe("LESY:Loader", () => {
6969
).toEqual(2);
7070
});
7171

72+
it("should exclude file with _ prefix", () => {
73+
expect(loader["isAllowedFile"](p`dummy.file`)).toBeTruthy();
74+
expect(loader["isAllowedFile"](p`_dummy.file`)).toBeFalsy();
75+
});
76+
7277
it("should exclude invalid files", () => {
7378
expect(loader["isAllowedFile"](p`dummy.file`)).toBeTruthy();
7479
const allowDefFile = flavor === "js";

packages/core/src/command.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ class LesyCommand {
128128
}
129129

130130
private normalizeCmdNames(cmd) {
131+
if (!cmd.name) cmd.name = "default";
131132
const names = [cmd.name, ...cmd.aliases].map((n: string) =>
132133
this.normalizeStr(n),
133134
);

packages/core/src/loader.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ class LesyLoader {
193193
}
194194

195195
private isAllowedFile(path: string) {
196+
if (path.startsWith("_")) return false;
196197
const ext = path.split(".");
197198
const lastIndex = ext.length - 1;
198199
if (process.env.LESY_LANG === "js") {

0 commit comments

Comments
 (0)