gadicc / meteor-messageformat

MessageFormat i18n support for Meteor, with reactive templates
54 stars 22 forks source link

[v2] extract Exception in callback of async function #214

Closed MartinFournier closed 8 years ago

MartinFournier commented 8 years ago

Hello, either since updating to Meteor 1.3 or extract preview 14 (both were done at the same time), the extraction constantly throws exceptions.

meteor shell
msgfmt.forceExtract();
'Forcing (re)-extract of all files and keys.  See results in main console log, according to your default debug level'

Running with extractLogLevel: 'debug'

I20160331-14:26:09.582(-4)? 2016-03-31 14:26:09.581 debug:  [msgfmt:extracts]  Checking for changed files...
I20160331-14:26:09.593(-4)? 2016-03-31 14:26:09.592 debug:  [msgfmt:extracts]  Retrieved old file info from database (in a fiber) in 10ms
I20160331-14:26:13.308(-4)? 2016-03-31 14:26:13.308 debug:  [msgfmt:extracts]  Finished walking files (non-fiber async) in 13891ms
I20160331-14:26:13.941(-4)? Exception in callback of async function: TypeError: Object [object Object] has no method ''
I20160331-14:26:13.941(-4)?     at packages/msgfmt_extract.js:119:45
I20160331-14:26:13.941(-4)?     at runWithEnvironment (packages/meteor.js:1154:24)
I20160331-14:26:20.591(-4)? 2016-03-31 14:26:20.590 debug:  [msgfmt:extracts]  Finished walking files (non-fiber async) in 10998ms

It seems to be line 96 of extract, probably when the walker hits a file with no extension?

handlers[path.extname(name).substr(1)](name, content, mtime, newStrings);

EDIT: The extract seem to hit files in node_modules

I20160331-15:02:24.416(-4)? 2016-03-31 15:02:24.400 debug:  [msgfmt:extracts]  Extracting from node_modules/shelljs/src/toEnd.js
I20160331-15:02:24.416(-4)? 2016-03-31 15:02:24.400 debug:  [msgfmt:extracts]  Extracting from node_modules/shelljs/src/touch.js
I20160331-15:02:24.416(-4)? 2016-03-31 15:02:24.400 debug:  [msgfmt:extracts]  Extracting from node_modules/shelljs/src/which.js
I20160331-15:02:24.416(-4)? 2016-03-31 15:02:24.400 debug:  [msgfmt:extracts]  Extracting from node_modules/shelljs/scripts/generate-docs.js
I20160331-15:02:24.416(-4)? 2016-03-31 15:02:24.400 debug:  [msgfmt:extracts]  Extracting from node_modules/shelljs/scripts/run-tests.js
I20160331-15:02:24.417(-4)? 2016-03-31 15:02:24.400 debug:  [msgfmt:extracts]  Extracting from node_modules/shelljs/build/output.js
I20160331-15:02:24.417(-4)? 2016-03-31 15:02:24.401 debug:  [msgfmt:extracts]  Extracting from node_modules/shelljs/bin/shjs
I20160331-15:02:24.417(-4)? Exception in callback of async function: TypeError: Object [object Object] has no method ''
I20160331-15:02:24.417(-4)?     at packages/msgfmt_extract.js:120:45
I20160331-15:02:24.417(-4)?     at runWithEnvironment (packages/meteor.js:1154:24)
gadicc commented 8 years ago

You were right twice. I added a fix too for files ending with a "known extension" that didn't include the dot (my bad).

As I wrote in the PR (thanks again): Published as v2.0.0. (Package seems pretty stable. Was thinking of switching to using the build plugin architecture before v2 final, but can foresee some problems with that, and we can always do a major bump if we do that change).