Skip to content

Commit 20afb46

Browse files
committed
Can migrate pods with undefined podModulePrefix
1 parent f1a47c7 commit 20afb46

14 files changed

Lines changed: 55 additions & 24 deletions

File tree

lib/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ var Engine = CoreObject.extend({
144144
var fileInfo = this.engine.buildFor(path, {
145145
projectRoot: this.projectRoot,
146146
projectName: this.projectName,
147-
podModulePrefix: this.podModulePrefix !== undefined ? this.podModulePrefix : 'pods',
147+
podModulePrefix: this.podModulePrefix || '',
148148
_fileInfoCollection: this._fileInfoCollection
149149
});
150150

lib/models/file-info.js

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,6 @@ var FileInfo = CoreObject.extend({
7575
var pathParts = this.sourceRelativePath.split('/');
7676
var typeFolder = pathParts[1];
7777

78-
79-
8078
var podType = typeForPodFile(this.sourceRelativePath);
8179
var arePodsNamespaced = hasPodNamespace(this.podModulePrefix);
8280

@@ -95,16 +93,19 @@ var FileInfo = CoreObject.extend({
9593
}
9694
}
9795

96+
strippedRelativePath = this.sourceRelativePath;
97+
9898
// default/classic/namespaced-pods
99-
pathRootRegex = new RegExp('(app\/)?' + this.podModulePrefix + '\/(components\/)?');
99+
if (this.podModulePrefix) {
100+
pathRootRegex = new RegExp('(app\/)?' + this.podModulePrefix + '\/(components\/)?');
101+
strippedRelativePath = strippedRelativePath.replace(pathRootRegex, ''); // don't care if path begins with pods;
102+
}
100103

101-
strippedRelativePath = this.sourceRelativePath
102-
.replace(pathRootRegex, '') // don't care if path begins with pods
104+
strippedRelativePath = strippedRelativePath
103105
.replace(new RegExp('^' + this.sourceRoot + '/' + typeFolder + '/'), '') // remove leading type dir
104106
.replace(new RegExp(this.ext + '$'), '') // remove extension
105107
.replace(new RegExp('/' + this.type + '$'), ''); // remove trailing type
106108

107-
108109
if (!arePodsNamespaced) {
109110
if (podType) {
110111
fileName = pathParts[pathParts.length - 1];
@@ -121,23 +122,6 @@ var FileInfo = CoreObject.extend({
121122
.replace(new RegExp(this.ext + '$'), '') // remove extension
122123
.replace(new RegExp('/' + this.type + '$'), ''); // remove trailing type
123124
}
124-
125-
// for other files (adapters, serializers, helpers, initializers, etc)
126-
if (type === undefined){
127-
pathRootRegex = new RegExp('(app\/)?');
128-
type = pathParts[1];
129-
fileName = pathParts[pathParts.length - 1];
130-
typeFolder = inflection.pluralize(type);
131-
132-
133-
strippedRelativePath = this.sourceRelativePath
134-
.replace(pathRootRegex, '')
135-
.replace(new RegExp(type + '/'), '')
136-
.replace(new RegExp('^' + this.sourceRoot + '/' + typeFolder + '/'), '') // remove leading type dir
137-
.replace(new RegExp(this.ext + '$'), '') // remove extension
138-
.replace(new RegExp('/' + this.type), ''); // remove trailing type
139-
140-
}
141125
}
142126

143127
var parts = strippedRelativePath.split('/');

test/fixtures/classic-acceptance/input.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,13 @@ module.exports = {
9797
}
9898
},
9999

100+
'config': {
101+
'environment.js': '"ENV"',
102+
'foo': {
103+
'baz.sh': 'yolo'
104+
}
105+
},
106+
100107
'tests': {
101108
'acceptance': {
102109
'post-test.js': '"post acceptance test"'

test/fixtures/classic-acceptance/output.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,12 @@ module.exports = {
126126
}
127127
}
128128
},
129+
'config': {
130+
'environment.js': '"ENV"',
131+
'foo': {
132+
'baz.sh': 'yolo'
133+
}
134+
},
129135
'tests': {
130136
'acceptance': {
131137
'post-test.js': '"post acceptance test"'
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
podModulePrefix: 'pods'
3+
};

test/fixtures/pods-acceptance/input.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,12 @@ module.exports = {
9696
'blahzorz.js': '"blahzorz validator"'
9797
}
9898
},
99+
'config': {
100+
'environment.js': '"ENV"',
101+
'foo': {
102+
'baz.sh': 'yolo'
103+
}
104+
},
99105
'tests': {
100106
'acceptance': {
101107
'post-test.js': '"post acceptance test"'

test/fixtures/pods-custom-name-acceptance/input.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,12 @@ module.exports = {
9696
'blahzorz.js': '"blahzorz validator"'
9797
}
9898
},
99+
'config': {
100+
'environment.js': '"ENV"',
101+
'foo': {
102+
'baz.sh': 'yolo'
103+
}
104+
},
99105
'tests': {
100106
'acceptance': {
101107
'post-test.js': '"post acceptance test"'
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
podModulePrefix: 'pods'
3+
};
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
podModulePrefix: 'pods'
3+
};
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
podModulePrefix: undefined
3+
};

0 commit comments

Comments
 (0)