Skip to content

Commit

Permalink
(fix) Correctly export controllers of modules when Windows paths
Browse files Browse the repository at this point in the history
Before this, the name of an exported controller would be identical
to its absolute path when Windows, e.g.

Unix
/path/to/my/controller.js --> controller

Windows
C:/path/to/my/controller.js --> C:/path/to/my/controller
  • Loading branch information
noodle committed Feb 4, 2018
1 parent ef7d831 commit 562339c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion legacy/manager.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,8 @@ ServiceManager.export = function (serviceName) {
var files = glob.sync(filePath + path.sep + 'controllers' + path.sep + '*.js');
// console.log('files:', files);
_.forEach(files, function (file) {
var parts = file.split(path.sep);
// "glob.sync" returns paths with normalized separators, so use "/" over path.sep here
var parts = file.split('/');
var name = parts.pop();
name = name.split('.')[0]; // remove '.js' from name
service.controller[name] = {
Expand Down
3 changes: 2 additions & 1 deletion lib/manager.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,8 @@ ServiceManager.export = function (serviceName) {
var files = glob.sync(filePath + path.sep + 'controllers' + path.sep + '*.js');
// console.log('files:', files);
_.forEach(files, function (file) {
var parts = file.split(path.sep);
// "glob.sync" returns paths with normalized separators, so use "/" over path.sep here
var parts = file.split('/');
var name = parts.pop();
name = name.split('.')[0]; // remove '.js' from name
service.controller[name] = {
Expand Down

0 comments on commit 562339c

Please sign in to comment.