Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong sorting in files - latest version #25

Open
oviava opened this issue Mar 19, 2015 · 3 comments
Open

Wrong sorting in files - latest version #25

oviava opened this issue Mar 19, 2015 · 3 comments

Comments

@oviava
Copy link

oviava commented Mar 19, 2015

Directory structure:
screen shot 2015-03-19 at 3 34 30 pm

Main app code:

(function () {

    'use strict';

    var module = angular.module('janus', ['janus.common', 'janus.security','janus.admin']);

}());

Gulp:

 var injectScripts = gulp.src([
         //paths.src + '/app/app.js',
         paths.src + '/app/**/*.js',
         '!' + paths.src + '/app/**/*.spec.js',
         '!' + paths.src + '/app/**/*.mock.js'
     ]).pipe($.naturalSort())
         .pipe($.angularFilesort());

My main app is added after janus.security & janus.common .. I've read the previous issues in here but can't seem to get this fixed.

@joakimbeng
Copy link
Member

Do you get any module loading error from Angular? What did you expect the sort order to be?
Your main app module is dependent on janus.common, etc, so it's logical that it's added after those modules.

@schmitch
Copy link

i think he has the same problem than me.

security depends on common, but common gets imported first.

@joakimbeng
Copy link
Member

I have a hard time trying to recreate your issue.

I've created a simple app with the following structure:

├── app.js   # declares app, depends on mod1, mod2, mod3
├── index.html
├── mod1
│   ├── mod1-ctrl.js  # depends on mod1
│   └── mod1.js   # declares mod1, depends on mod2
├── mod2
│   ├── mod2-ctrl.js   # depends on mod2
│   ├── mod2-service.js  # depends on mod2
│   └── mod2.js  # declares mod2, depends on nothing
└── mod3
    ├── mod3-ctrl.js  # depends on mod3
    └── mod3.js  # declares mod3, depends on mod2

When running gulp-angular-filesort i get the following sortorder which is put in index.html:

  <script src="mod3/mod3.js"></script>
  <script src="mod3/mod3-ctrl.js"></script>
  <script src="mod2/mod2.js"></script>
  <script src="mod2/mod2-ctrl.js"></script>
  <script src="mod2/mod2-service.js"></script>
  <script src="mod1/mod1.js"></script>
  <script src="mod1/mod1-ctrl.js"></script>
  <script src="app.js"></script>

When opening index.html I get no errors and the app works as expected. It does not matter that mod3 is sorted before mod2, angular does not care about that, the important part is that each module is sorted before their respective controllers, services, etc.

You can download the sample files here yourself: https://drive.google.com/file/d/0Bw3qo-O7AmgId3gySmhNUHlJV2s/view?usp=sharing

Is there anything I'm missing?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants