Skip to content

Commit

Permalink
fix: glob pattern in push + tests
Browse files Browse the repository at this point in the history
  • Loading branch information
stepan662 committed Dec 3, 2024
1 parent afaa272 commit 41c83e2
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 5 deletions.
4 changes: 3 additions & 1 deletion src/commands/push.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ type PushOptions = BaseOptions & {

async function allInPattern(pattern: string) {
const files: File[] = [];
const items = await glob(pattern);
const items = await glob(pattern, {
windowsPathsNoEscape: process.platform === 'win32',
});
for (const item of items) {
if ((await stat(item)).isDirectory()) {
files.push(...(await readDirectory(item)));
Expand Down
1 change: 1 addition & 0 deletions src/config/tolgeerc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ function parseConfig(input: Schema, configDir: string): Schema {
}));
}

// convert relative paths in config to absolute
if (rc.pull?.path !== undefined) {
rc.pull.path = resolve(configDir, rc.pull.path);
}
Expand Down
3 changes: 3 additions & 0 deletions test/__fixtures__/validTolgeeRc/i18n/en.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"test": "Test"
}
3 changes: 3 additions & 0 deletions test/__fixtures__/validTolgeeRc/src/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function App() {
return null;
}
14 changes: 10 additions & 4 deletions test/unit/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { fileURLToPath } from 'url';
import { MockInstance, vi } from 'vitest';

import loadTolgeeRc from '#cli/config/tolgeerc.js';
import { glob } from 'glob';

const FIXTURES_PATH = new URL('../__fixtures__/', import.meta.url);

Expand Down Expand Up @@ -73,13 +74,18 @@ describe('.tolgeerc', () => {
const cfg = (await loadTolgeeRc(path))!;

// make sure all paths in the config file are expanded relatively to the config location
[
for (const path of [
cfg.extractor,
...cfg.patterns!,
...cfg.push!.files!.map((f) => f.path),
].forEach((path) => {
expect(path).toMatch(/[/\\]validTolgeeRc[/\\]/);
});
]) {
expect(path).toMatch(/[^/\\][/\\]validTolgeeRc[/\\][^/\\]/);
expect(
await glob(path!, {
windowsPathsNoEscape: process.platform === 'win32',
})
).length.above(0);
}
});

it('converts projectId to number', async () => {
Expand Down

0 comments on commit 41c83e2

Please sign in to comment.