Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running command as a npm script fails #76

Open
vlad-nica opened this issue Apr 25, 2017 · 5 comments
Open

Running command as a npm script fails #76

vlad-nica opened this issue Apr 25, 2017 · 5 comments

Comments

@vlad-nica
Copy link

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!

@evenchange4
Copy link
Owner

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.

@vlad-nica
Copy link
Author

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 😊

@evenchange4
Copy link
Owner

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. 👌🏻

@ybelenko
Copy link

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.

@samkelleher
Copy link

Same problem in macos, the pot file is generated empty. Regardless of run via yarn script or directly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants