Skip to content
This repository was archived by the owner on Jan 3, 2024. It is now read-only.

Commit 74758a6

Browse files
committed
fix: Clarify error message when non-magical part of input glob does not exist
1 parent 4c57e30 commit 74758a6

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

core/garment/__tests__/garment.test.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,21 @@ describe('createFileInput', () => {
6363

6464
expect(filesCount).toBe(2);
6565
});
66+
67+
test('should throw with a clear error message when rootDir does not exist', async () => {
68+
const testDir = await initFixture('basic');
69+
70+
const nonExistingDirectory = Path.join(testDir, 'nonExistingDirectory');
71+
const generator = createFileInput({
72+
rootDir: nonExistingDirectory
73+
});
74+
75+
const createFileInputForNonExistingRootDirectory = () => {
76+
generator.next();
77+
};
78+
79+
expect(createFileInputForNonExistingRootDirectory).toThrow(
80+
/nonExistingDirectory/
81+
);
82+
});
6683
});

core/garment/src/garment.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1083,6 +1083,11 @@ export function* createFileInput(
10831083
{ rootDir, files = [], include, exclude = [] }: Input,
10841084
fsInstance = fs
10851085
) {
1086+
if (!fsInstance.existsSync(rootDir)) {
1087+
throw new Error(`The path ${rootDir} does not exist, please check the input property
1088+
of your tasks in your garment.json file and verify that the "non-magical" part of your glob
1089+
is a path to an already existing directory`);
1090+
}
10861091
const filesFromGlob = include
10871092
? globby.sync(include, {
10881093
cwd: rootDir,

0 commit comments

Comments
 (0)