lazd / gulp-declare

Safely declare namespaces and set their properties
MIT License
17 stars 3 forks source link

Mysterious dots prepended in ``.processNameByPath`` #4

Open afoeder opened 10 years ago

afoeder commented 10 years ago

I am trying to adjust the processName but get three leading dots after applying declare.processNameByPath:

gulp.src(['../Packages/Application/Acme.Ui/Resources/Private/Scripts/Ember/Templates/**/*.hbs'])
    .pipe(handlebars({ handlebars: require('ember-handlebars') }))
    .pipe(wrap('Ember.Handlebars.template(<%= contents %>)'))
    .pipe(declare({
        namespace: 'Ember.TEMPLATES',
        noRedeclare: true,
        processName: function(filePath) {
            // filePath is ``/Users/afoeder/PhpstormProjects/acme/Distribution/Packages/Application/Acme.Ui/Resources/Private/Scripts/Ember/Templates/Login.js``
            // declare.processNameByPath(filePath) is ``...Packages.Application.Wishbase.Ui.Resources.Private.Scripts.Ember.Templates.Login.``

            return declare.processNameByPath(filePath.replace('Packages/Application/Wishbase.Ui/Resources/Private/Scripts/Ember/Templates/', ''));
            // this, however, will still return ``...Login``
        }
}))

The location of the gulpfile is at /Users/afoeder/PhpstormProjects/acme/Distribution/Build/, is this maybe the reason why some relative path determinition doesn't work well?

Thanks for your support!

lazd commented 10 years ago

Hey @afoeder, I agree declare.processNameByPath() should handle this case. In the mean time, you can remove the ../ from the path in your replace() and things should behave as expected.