react-intl-po
react-intl-po copied to clipboard
Running command as a npm script fails
So I bumped into the following issue: running rip json2pot 'i18n/messages/**/*.json' -o ./i18n/template.pot in the console works properly, whilst putting the command in package.json as a script and running it like npm run i18n-extract, generates an empty .pot file.
"scripts": {
"i18n-extract": "rip json2pot 'i18n/messages/**/*.json' -o ./i18n/template.pot"
}
Thanks!
I have no idea how it happened. Could you provide your project so I can reproduce? Or, you could take a look at this standalone repository for the settings.
Sorry for the late response but at least I'm coming back with a solution...the problem were the single quotes. If you run the command like rip json2pot 'i18n/messages/**/*.json' -o 'i18n/template.pot' the command crashes: Error: ENOENT: no such file or directory, open 'C:\Playground\react-intl-po-example\'output\messages.json''. (yes, I know ... windows). If you run it in console with quotes only for the first argument, everything works well. Same if you run it without any quotes at all. Now for npm script, it doesn't work. Why? I have no clue. But having no quotes in the command (on windows), will make things work in both console and npm scripts.
Sorry for the false alarm 😊
But having no quotes in the command (on windows), will make things work in both console and npm scripts.
I think you already find a solution. I am not familiar with Windows' command. Maybe the document can be improved more Windows-friendly. Close it for now. Any further PRs are always welcome. 👌🏻
Got the same problem on Windows 8.1.
$ npm -v
5.6.0
$ node -v
v8.11.1
Script doesn't work from npm run but does work from cmd. Problem definitely relates to current path.
{
"scripts": {
"json2pot": "rip json2pot './build/messages/**/*.json' -o ./src/locales/translations.pot",
"po2json": "rip po2json './src/locales/he.po' -m './build/messages/**/*.json' -o ./src/locales/translations.json"
}
}
So
npm run json2pot
npm run po2json
produces empty files. Meantime in command line
$ node_modules/.bin/react-intl-po json2pot './build/messages/**/*.json' -o ./src/locales/translations.pot
$ node_modules/.bin/react-intl-po po2json './src/locales/he.po' -m './build/messages/**/*.json' -o ./src/locales/translations.json
works perfect.
Same problem in macos, the pot file is generated empty. Regardless of run via yarn script or directly.