Skip to content

Commit cbe5d74

Browse files
authored
fix: Ignore not lang folders. (#39)
1 parent 4483c1f commit cbe5d74

File tree

3 files changed

+27
-12
lines changed

3 files changed

+27
-12
lines changed

package-lock.json

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/loader.ts

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,18 +52,26 @@ export const parseAll = (folderPath: string): { name: string; path: string }[] =
5252
})
5353
}
5454

55-
return data.map(({ folder, translations }) => {
56-
const name = `php_${folder}.json`
57-
const path = folderPath + name
55+
return data
56+
.filter(({ translations }) => {
57+
return Object.keys(translations).length > 0
58+
})
59+
.map(({ folder, translations }) => {
60+
const name = `php_${folder}.json`
61+
const path = folderPath + name
5862

59-
fs.writeFileSync(path, JSON.stringify(translations))
60-
return { name, path }
61-
})
63+
fs.writeFileSync(path, JSON.stringify(translations))
64+
return { name, path }
65+
})
6266
}
6367

6468
export const parse = (content: string) => {
6569
const arr = new Engine({}).parseCode(content, 'lang').children.filter((child) => child.kind === 'return')[0] as any
6670

71+
if (arr?.expr?.kind !== 'array') {
72+
return {}
73+
}
74+
6775
return convertToDotsSyntax(parseItem(arr.expr))
6876
}
6977

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
3+
function foo() {
4+
return 'bar';
5+
}
6+
7+
return 'a';

0 commit comments

Comments
 (0)