Skip to content

Commit 3496530

Browse files
committed
Allow <name>.<ext> even with a namespace for default type in collection.
Based on rev.66.
1 parent b80eb99 commit 3496530

3 files changed

Lines changed: 7 additions & 38 deletions

File tree

lib/models/file-info.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
var path = require('path');
2-
var inflection = require('inflection');
32
var CoreObject = require('core-object');
43
var fse = require('fs-extra');
54
var existsSync = require('exists-sync');
@@ -156,12 +155,10 @@ var FileInfo = CoreObject.extend({
156155
return true;
157156
}
158157

159-
var singularizedCollection = inflection.singularize(this.collection);
160-
var isDefaultTypeForCollection = singularizedCollection === this.type;
161-
var hasNamespace = !!this.namespace;
158+
var isDefaultTypeForCollection = defaultTypeForCollection(this.collection) === this.type;
162159

163160
// use <name>.<ext> in the root of a collection if it is the default type
164-
return isDefaultTypeForCollection && !hasNamespace;
161+
return isDefaultTypeForCollection;
165162
}
166163
});
167164

Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,5 @@
1-
module.exports = function(collection) {
2-
switch(collection) {
3-
case 'models':
4-
return 'model';
5-
6-
case 'components':
7-
return 'component';
8-
9-
case 'initializers':
10-
return 'initializer';
11-
12-
case 'instance-initializers':
13-
return 'instance-initializer';
14-
15-
//case 'partials':
16-
// return 'partial';
1+
var inflection = require('inflection');
172

18-
case 'routes':
19-
return 'route';
20-
21-
case 'services':
22-
return 'service';
23-
24-
case 'transforms':
25-
return 'transform';
26-
27-
case 'utils':
28-
return 'util';
29-
30-
default:
31-
return null;
32-
}
3+
module.exports = function(collection) {
4+
return inflection.singularize(collection);
335
};

test/engines/classic-test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,9 @@ describe('classic engine', function() {
7171
'app/components/qux-derp/component.js': 'src/ui/components/qux-derp/component.js',
7272
'app/templates/components/foo-bar.hbs': 'src/ui/components/foo-bar/template.hbs',
7373
'app/components/qux-derp/template.hbs': 'src/ui/components/qux-derp/template.hbs',
74-
'app/routes/post/index.js': 'src/ui/routes/post/index/route.js',
74+
'app/routes/post/index.js': 'src/ui/routes/post/index.js',
7575
'app/templates/post/index.hbs': 'src/ui/routes/post/index/template.hbs',
76-
'app/routes/foo/bar/baz.js': 'src/ui/routes/foo/bar/baz/route.js',
76+
'app/routes/foo/bar/baz.js': 'src/ui/routes/foo/bar/baz.js',
7777
'app/templates/foo/bar/baz.hbs': 'src/ui/routes/foo/bar/baz/template.hbs',
7878
'app/adapters/post.js': 'src/data/models/post/adapter.js',
7979
'app/serializers/post.js': 'src/data/models/post/serializer.js',

0 commit comments

Comments
 (0)