Skip to content

Commit e006052

Browse files
author
Kelly Selden
authored
Merge pull request #66 from kellyselden/node4
fix node 4
2 parents 45c51c6 + c41cbff commit e006052

1 file changed

Lines changed: 20 additions & 9 deletions

File tree

transform.js

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,11 @@ function transform(file, api/*, options*/) {
287287
// just "Ember.computed"—we want "Ember.computed.or" as well.
288288
let candidates = expandMemberExpressions(path);
289289
if (namespace) {
290-
candidates = candidates.map(([path, propertyPath]) => [path, `${namespace}.${propertyPath}`]);
290+
candidates = candidates.map(expression => {
291+
let path = expression[0];
292+
let propertyPath = expression[1];
293+
return [path, `${namespace}.${propertyPath}`];
294+
});
291295
}
292296

293297
// This will give us an array of tuples ([pathString, node]) that represent
@@ -298,7 +302,10 @@ function transform(file, api/*, options*/) {
298302
//
299303
// We'll go through these to find the most specific candidate that matches
300304
// our global->ES6 map.
301-
let found = candidates.find(([_, propertyPath]) => propertyPath in mappings);
305+
let found = candidates.find(expression => {
306+
let propertyPath = expression[1];
307+
return propertyPath in mappings;
308+
});
302309

303310
// If we got this far but didn't find a viable candidate, that means the user is
304311
// using something on the `Ember` global that we don't have a module equivalent for.
@@ -307,7 +314,8 @@ function transform(file, api/*, options*/) {
307314
return null;
308315
}
309316

310-
let [nodePath, propertyPath] = found;
317+
let nodePath = found[0];
318+
let propertyPath = found[1];
311319
let mapping = mappings[propertyPath];
312320

313321
let mod = mapping.getModule();
@@ -443,7 +451,9 @@ function transform(file, api/*, options*/) {
443451

444452
registry.modules.forEach(mod => {
445453
if (!mod.node) {
446-
let { source, imported, local } = mod;
454+
let source = mod.source;
455+
let imported = mod.imported;
456+
let local = mod.local;
447457

448458
let declaration = root.find(j.ImportDeclaration, {
449459
source: { value: mod.source }
@@ -477,7 +487,8 @@ function transform(file, api/*, options*/) {
477487

478488
root
479489
.find(j.ImportDeclaration)
480-
.forEach(({ node }) => {
490+
.forEach(mod => {
491+
let node = mod.node;
481492
let source = node.source.value;
482493

483494
node.specifiers.forEach(spec => {
@@ -660,10 +671,10 @@ class Replacement {
660671
}
661672

662673
class Mapping {
663-
constructor({module, export: exportName, localName}, registry) {
664-
this.source = module;
665-
this.imported = exportName;
666-
this.local = localName;
674+
constructor(options, registry) {
675+
this.source = options.module;
676+
this.imported = options.export;
677+
this.local = options.localName;
667678
this.registry = registry;
668679
}
669680

0 commit comments

Comments
 (0)