fivetanley / ember-cli-migrator

migrate your files to the standard ember-cli structure, preserving git history
MIT License
106 stars 22 forks source link

Error running migrator #68

Open lifeinafolder opened 9 years ago

lifeinafolder commented 9 years ago

I tried to migrate an ember app but ran into the following issue:

Preprocessing files
Failed to parse app.js
Note that you probably don't want to run the migrator against your npm or bower dependencies. Make sure that the directory you've specified in the '--source' flag only contains your application code.
Error: Line 12: Unexpected token ILLEGAL
/usr/local/lib/node_modules/ember-cli-migrator/lib/ember-migrator.js:189
  var astBody = ast.program.body;
                   ^
TypeError: Cannot read property 'program' of undefined
    at EmberMigrator.splitFile (/usr/local/lib/node_modules/ember-cli-migrator/lib/ember-migrator.js:189:20)
    at Array.forEach (native)
    at EmberMigrator_run [as run] (/usr/local/lib/node_modules/ember-cli-migrator/lib/ember-migrator.js:82:11)
    at Object.<anonymous> (/usr/local/lib/node_modules/ember-cli-migrator/bin/ember-cli-migrator:30:10)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Function.Module.runMain (module.js:501:10)
    at startup (node.js:129:16)

I am using Ember-Rails gem. Any help would be appreciated.

igorT commented 9 years ago

How does your app.js look like?

lifeinafolder commented 9 years ago
Test = Ember.Namespace.create();

Test.App = Ember.Application.create({
  data: [], // some static data as placeholder for a BE response
  ready: function () {
    console.log('Ember Application Ready');
  }
});
igorT commented 9 years ago

I am not sure we support custom namespaces, maybe @fivetanley or @tonysherbondy know

Mitchal commented 7 years ago

I experience the same issue. Is there any solution?

hefox commented 6 years ago

This error happens when recast is unable to parse a file, e.g. the Error: Line 12: Unexpected token ILLEGAL is it's parse error for app.js

However, it's not returning after catching the error which means it's goes to the next step with an invalid object, added a PR https://github.com/fivetanley/ember-cli-migrator/pull/83 to fix the error handling.

igorT commented 6 years ago

Thanks a bunch for the fix. I merged the PR

hefox commented 6 years ago

https://github.com/fivetanley/ember-cli-migrator/pull/84 so far this appears to fix the errors I saw