Skip to content

Commit f426881

Browse files
author
Sergio Moreno
committed
fix: lingui extract ignores custom directories as args #998
1 parent 9e68a8d commit f426881

3 files changed

Lines changed: 77 additions & 49 deletions

File tree

examples/create-react-app/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "0.1.0",
44
"private": true,
55
"dependencies": {
6-
"@lingui/react": "^3.2.3",
6+
"@lingui/react": "latest",
77
"@testing-library/jest-dom": "^5.11.5",
88
"@testing-library/react": "^11.1.0",
99
"@testing-library/user-event": "^12.1.10",
@@ -41,8 +41,8 @@
4141
]
4242
},
4343
"devDependencies": {
44-
"@lingui/cli": "^3.5.1",
45-
"@lingui/loader": "^3.5.1",
46-
"@lingui/macro": "^3.5.1"
44+
"@lingui/cli": "latest",
45+
"@lingui/loader": "latest",
46+
"@lingui/macro": "latest"
4747
}
4848
}

examples/create-react-app/yarn.lock

Lines changed: 58 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1418,31 +1418,32 @@
14181418
"@types/yargs" "^15.0.0"
14191419
chalk "^4.0.0"
14201420

1421-
"@lingui/babel-plugin-extract-messages@^3.5.1":
1422-
version "3.5.1"
1423-
resolved "https://registry.yarnpkg.com/@lingui/babel-plugin-extract-messages/-/babel-plugin-extract-messages-3.5.1.tgz#998ecb93bd07ef2980ae815eb42e1729926eb4f7"
1424-
integrity sha512-uPMEbe5r3Zj3KVd6XTln8LTUik+lavsrf18FssiiuGNg7c0QoihsO2xnJjONSdpM30yVwZGLO1nhM/lEB08XcQ==
1421+
"@lingui/babel-plugin-extract-messages@^3.7.1":
1422+
version "3.7.1"
1423+
resolved "https://registry.yarnpkg.com/@lingui/babel-plugin-extract-messages/-/babel-plugin-extract-messages-3.7.1.tgz#320d09aafa8874299765055b790b6f4e3fa2646b"
1424+
integrity sha512-9U4sdsF6NWUcITkcms3lpgAwqWWmsqZA4XGX3jMwQL0axq2zNTOKIlZmyzOtiteuLcOA8sb4KkrRhz7N09n7UQ==
14251425
dependencies:
14261426
"@babel/generator" "^7.11.6"
14271427
"@babel/runtime" "^7.11.2"
1428-
"@lingui/conf" "^3.5.1"
1428+
"@lingui/conf" "^3.7.1"
14291429
mkdirp "^1.0.4"
14301430

1431-
"@lingui/cli@^3.5.1":
1432-
version "3.5.1"
1433-
resolved "https://registry.yarnpkg.com/@lingui/cli/-/cli-3.5.1.tgz#e2ac505358663214e608368cc22686c13f0764d0"
1434-
integrity sha512-34CieHCMgVgZqzR0mgw/ZD6zJ7I/HwloCgoKJGFd2IT53PusG89e8I5OvvlhnTL1sQhTPqABpBR+iu6LywGleQ==
1431+
"@lingui/cli@^3.7.1", "@lingui/cli@latest":
1432+
version "3.7.1"
1433+
resolved "https://registry.yarnpkg.com/@lingui/cli/-/cli-3.7.1.tgz#ce60aa4a2e6982c8dbed415b03d27a2de7c2dfbd"
1434+
integrity sha512-PMSJVK9URfop0+y4wxRs8XwIdNW2StjgqOVogBL5qxDdNZinGz5wUoVU/CNzgM3BAz6HaVm2ZGwIDa7j2s6VSA==
14351435
dependencies:
14361436
"@babel/generator" "^7.11.6"
14371437
"@babel/parser" "^7.11.5"
14381438
"@babel/plugin-syntax-jsx" "^7.10.4"
14391439
"@babel/runtime" "^7.11.2"
14401440
"@babel/types" "^7.11.5"
1441-
"@lingui/babel-plugin-extract-messages" "^3.5.1"
1442-
"@lingui/conf" "^3.5.1"
1441+
"@lingui/babel-plugin-extract-messages" "^3.7.1"
1442+
"@lingui/conf" "^3.7.1"
14431443
babel-plugin-macros "^2.8.0"
14441444
bcp-47 "^1.0.7"
14451445
chalk "^4.1.0"
1446+
chokidar "3.5.1"
14461447
cli-table "^0.3.1"
14471448
commander "^6.1.0"
14481449
date-fns "^2.16.1"
@@ -1458,15 +1459,16 @@
14581459
normalize-path "^3.0.0"
14591460
ora "^5.1.0"
14601461
papaparse "^5.3.0"
1462+
pkg-up "^3.1.0"
14611463
plurals-cldr "^1.0.4"
14621464
pofile "^1.1.0"
14631465
pseudolocale "^1.1.0"
14641466
ramda "^0.27.1"
14651467

1466-
"@lingui/conf@^3.5.1":
1467-
version "3.5.1"
1468-
resolved "https://registry.yarnpkg.com/@lingui/conf/-/conf-3.5.1.tgz#3d9ff58d4881a08f3bb2e42b06e86e926d568281"
1469-
integrity sha512-N8LfbgJUFSBFTC85+BhmbZ2B+N3a4wTPjhJxohE4n8T/mA0LnxVkC1ldgZxZG6IKYxb2D9acxyLTxTh064Kr9A==
1468+
"@lingui/conf@^3.7.1":
1469+
version "3.7.1"
1470+
resolved "https://registry.yarnpkg.com/@lingui/conf/-/conf-3.7.1.tgz#14679e246a07d2822656d73e897bf96944510328"
1471+
integrity sha512-D80MjeLdV2YN+Nti4+hOh0qWhgZZa10iosKLpdXVxVrC9MCGa3XxPcaeK2EaRlbjgCCMmDZHghzKA7WOg67EkQ==
14701472
dependencies:
14711473
"@babel/runtime" "^7.11.2"
14721474
"@endemolshinegroup/cosmiconfig-typescript-loader" "^3.0.2"
@@ -1475,42 +1477,42 @@
14751477
jest-validate "^26.5.2"
14761478
lodash.get "^4.4.2"
14771479

1478-
"@lingui/core@^3.2.3":
1479-
version "3.2.3"
1480-
resolved "https://registry.yarnpkg.com/@lingui/core/-/core-3.2.3.tgz#2eeba173d3a3a1cbe9f9de4ed57380d2dc45ecff"
1481-
integrity sha512-TiWk6LGjZ9sNVi7itiJDWUIB1Uyr8WKR/8M6RhQVTRnL+Yh3mElsVPjIRPH1he4ClkwaH6G5eDOfWiB67Csgbw==
1480+
"@lingui/core@^3.7.1":
1481+
version "3.7.1"
1482+
resolved "https://registry.yarnpkg.com/@lingui/core/-/core-3.7.1.tgz#c67b6aee648ee226742d77fe0214383e16672b91"
1483+
integrity sha512-VJeyjVTvgc3FcILIGBtu0m4CxIqw9cHAU93dCN7wlI074hn+KtZZxI47pzViRqmpDknLcriZ5Ua7GqP3IpHadA==
14821484
dependencies:
14831485
"@babel/runtime" "^7.11.2"
14841486
make-plural "^6.2.2"
14851487
messageformat-parser "^4.1.3"
14861488

1487-
"@lingui/loader@^3.5.1":
1488-
version "3.5.1"
1489-
resolved "https://registry.yarnpkg.com/@lingui/loader/-/loader-3.5.1.tgz#b79045996246c3b7a2e1198c361b91a44c388aea"
1490-
integrity sha512-IfalTjtIN8DsAhYozaKI2to0a+MGD553cVjXrKuTv9gO6Sr0cg1Y6ryCbdPhsbf9kQx3PLIcBVAi0qsjcW4xfA==
1489+
"@lingui/loader@latest":
1490+
version "3.7.1"
1491+
resolved "https://registry.yarnpkg.com/@lingui/loader/-/loader-3.7.1.tgz#3f65c89cfbce717d0e14d6cc973ef7d9cd247f5a"
1492+
integrity sha512-hsFnaI3pnBDqj8JEwGKXcU2bGYesM7STaNcDnVNazfw2j2lGTxP6yeQdA7mVeTXq+DzEa6jr7ksqYTuzRBLLlA==
14911493
dependencies:
14921494
"@babel/runtime" "^7.11.2"
1493-
"@lingui/cli" "^3.5.1"
1494-
"@lingui/conf" "^3.5.1"
1495+
"@lingui/cli" "^3.7.1"
1496+
"@lingui/conf" "^3.7.1"
14951497
loader-utils "^2.0.0"
14961498
ramda "^0.27.1"
14971499

1498-
"@lingui/macro@^3.5.1":
1499-
version "3.5.1"
1500-
resolved "https://registry.yarnpkg.com/@lingui/macro/-/macro-3.5.1.tgz#130b6b56982fc8ae63bd534651137b61a1b32f97"
1501-
integrity sha512-hLMCcA4ocBsemjCJFPQnW43jDvSv8xOovIDzcjh1dFQP5EjdRGyJRjmqaC3d3v3b8LpdUKN//EChLAF/dwwGrw==
1500+
"@lingui/macro@latest":
1501+
version "3.7.1"
1502+
resolved "https://registry.yarnpkg.com/@lingui/macro/-/macro-3.7.1.tgz#6d9d0c262e2841f4f329c9a31ec897f4d2fb0964"
1503+
integrity sha512-dQ5TIshKbDFoLkCdQZIGgZkwYmEjKrBi7toMtt1j2BF3sPkijFGa0eFKHZA/2QEbx/uqwv8TbzqpJ3OH7JTDSg==
15021504
dependencies:
15031505
"@babel/runtime" "^7.11.2"
1504-
"@lingui/conf" "^3.5.1"
1506+
"@lingui/conf" "^3.7.1"
15051507
ramda "^0.27.1"
15061508

1507-
"@lingui/react@^3.2.3":
1508-
version "3.2.3"
1509-
resolved "https://registry.yarnpkg.com/@lingui/react/-/react-3.2.3.tgz#8cf78a217d4a2314ab38c68521a6dd544f87b258"
1510-
integrity sha512-oPqy7LhJddBDvgDvfKikZh8sFP4uG1/NaDhIkHXVCwf+ONxuAwsDPvW47e/K5hQ60UX2LqGbbB7LuAFK5Klr1Q==
1509+
"@lingui/react@latest":
1510+
version "3.7.1"
1511+
resolved "https://registry.yarnpkg.com/@lingui/react/-/react-3.7.1.tgz#4f71ef7082405c90534ba8ea02284c9f5102401d"
1512+
integrity sha512-ZXs4RdJdfMAXBwxxZrw/Ytts6YqTSIR3VTbQ04yqPFmCBp1f1gsz4ejrN7oHhgrCiNImbT7UNK+byn2NnfbhVA==
15111513
dependencies:
15121514
"@babel/runtime" "^7.11.2"
1513-
"@lingui/core" "^3.2.3"
1515+
"@lingui/core" "^3.7.1"
15141516

15151517
"@nodelib/fs.scandir@2.1.3":
15161518
version "2.1.3"
@@ -3336,6 +3338,21 @@ check-types@^11.1.1:
33363338
resolved "https://registry.yarnpkg.com/check-types/-/check-types-11.1.2.tgz#86a7c12bf5539f6324eb0e70ca8896c0e38f3e2f"
33373339
integrity sha512-tzWzvgePgLORb9/3a0YenggReLKAIb2owL03H2Xdoe5pKcUyWRSEQ8xfCar8t2SIAuEDwtmx2da1YB52YuHQMQ==
33383340

3341+
chokidar@3.5.1:
3342+
version "3.5.1"
3343+
resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-3.5.1.tgz#ee9ce7bbebd2b79f49f304799d5468e31e14e68a"
3344+
integrity sha512-9+s+Od+W0VJJzawDma/gvBNQqkTiqYTWLuZoyAsivsI4AaWTCzHG06/TMjsf1cYe9Cb97UCEhjz7HvnPk2p/tw==
3345+
dependencies:
3346+
anymatch "~3.1.1"
3347+
braces "~3.0.2"
3348+
glob-parent "~5.1.0"
3349+
is-binary-path "~2.1.0"
3350+
is-glob "~4.0.1"
3351+
normalize-path "~3.0.0"
3352+
readdirp "~3.5.0"
3353+
optionalDependencies:
3354+
fsevents "~2.3.1"
3355+
33393356
chokidar@^2.1.8:
33403357
version "2.1.8"
33413358
resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-2.1.8.tgz#804b3a7b6a99358c3c5c61e71d8728f041cff917"
@@ -5505,6 +5522,11 @@ fsevents@~2.1.2:
55055522
resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.1.2.tgz#4c0a1fb34bc68e543b4b82a9ec392bfbda840805"
55065523
integrity sha512-R4wDiBwZ0KzpgOWetKDug1FZcYhqYnUYKtfZYt4mD5SBz76q0KR4Q9o7GIPamsVPGmW3EYPPJ0dOOjvx32ldZA==
55075524

5525+
fsevents@~2.3.1:
5526+
version "2.3.2"
5527+
resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.2.tgz#8a526f78b8fdf4623b709e0b975c52c24c02fd1a"
5528+
integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==
5529+
55085530
function-bind@^1.1.1:
55095531
version "1.1.1"
55105532
resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d"
@@ -8568,7 +8590,7 @@ pkg-dir@^4.1.0, pkg-dir@^4.2.0:
85688590
dependencies:
85698591
find-up "^4.0.0"
85708592

8571-
pkg-up@3.1.0:
8593+
pkg-up@3.1.0, pkg-up@^3.1.0:
85728594
version "3.1.0"
85738595
resolved "https://registry.yarnpkg.com/pkg-up/-/pkg-up-3.1.0.tgz#100ec235cc150e4fd42519412596a28512a0def5"
85748596
integrity sha512-nDywThFk1i4BQK4twPQ6TA4RT8bDY96yeuCVBWL3ePARCiEKDRSrNGbFIgUJpLp+XeIR65v8ra7WuJOFUBtkMA==

packages/cli/src/lingui-extract.ts

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -134,25 +134,25 @@ if (require.main === module) {
134134
}
135135

136136
if (hasErrors) process.exit(1)
137-
138-
const extract = (filePath?: string) =>
139-
command(config, {
137+
138+
const extract = (filePath?: string[]) => {
139+
return command(config, {
140140
verbose: program.watch || program.verbose || false,
141141
clean: program.watch ? false : program.clean || false,
142142
overwrite: program.watch || program.overwrite || false,
143143
locale: program.locale,
144144
watch: program.watch || false,
145-
files: filePath ? [filePath] : undefined,
145+
files: filePath?.length ? filePath : undefined,
146146
prevFormat,
147147
})
148-
148+
}
149149

150150
// Check if Watch Mode is enabled
151151
if (program.watch) {
152152
console.info(chalk.bold("Initializing Watch Mode..."))
153153

154154
const catalogs = getCatalogs(config)
155-
let paths = [];
155+
let paths = [];
156156
let ignored = [];
157157

158158
catalogs.forEach((catalog) => {
@@ -166,14 +166,20 @@ if (require.main === module) {
166166
});
167167

168168
const onReady = () => {
169-
console.info(chalk.green.bold("Watcher is ready!"))
170-
watcher.on('add', (path) => extract(path)).on('change', (path) => extract(path));
169+
console.info(chalk.green.bold("Watcher is ready!"))
170+
watcher
171+
.on('add', (path) => extract([path]))
172+
.on('change', (path) => extract([path]));
171173
};
172174

173175
watcher.on('ready', () => onReady());
176+
} else if (program.args) {
177+
// this behaviour occurs when we extract files by his name
178+
// for ex: lingui extract src/app, this will extract only files included in src/app
179+
const result = extract(program.args);
180+
if (!result) process.exit(1)
174181
} else {
175182
const result = extract();
176-
177183
if (!result) process.exit(1)
178184
}
179185
}

0 commit comments

Comments
 (0)