Skip to content

Commit

Permalink
Fixed bad list module name in dist folder #63
Browse files Browse the repository at this point in the history
  • Loading branch information
Zizzamia committed Dec 10, 2014
1 parent ba5b4b8 commit c4cd9f3
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 42 deletions.
94 changes: 56 additions & 38 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,25 @@ var banner = ['/*',
' * Version: ' + pkg.version + ' - ' + moment().format("YYYY-MM-DD"),
' * License: ' + pkg.license,
' */\n'].join('\n');
var srcModules = [];
var tplModules = [];

var getExtension = function (filename) {
var i = filename.lastIndexOf('.');
return (i < 0) ? '' : filename.substr(i);
}

var capitaliseFirstLetter = function(string) {
var capitaliseFirstLetter = function (string) {
return string.charAt(0).toUpperCase() + string.slice(1);
}
var enquote = function (str) {
return '"' + str + '"';
}
var camelCase = function (input) {
return input.toLowerCase().replace(/-(.)/g, function(match, group1) {
return group1.toUpperCase();
});
}

gulp.task('clean', function () {
return gulp.src('dist', {read: false})
Expand Down Expand Up @@ -74,8 +89,8 @@ gulp.task('html2js', function() {
var path = file.path.split('/'),
folder = path[path.length - 2],
fileName = path[path.length - 1].split('.')[0];
var name = 'ngTasty.tpls.' + capitaliseFirstLetter(folder);
return name + capitaliseFirstLetter(fileName);
var name = 'ngTasty.tpls.' + camelCase(folder);
return name + '.' + camelCase(fileName);
},
prefix: "template/"
}))
Expand Down Expand Up @@ -111,7 +126,7 @@ gulp.task('full-test', function() {
'components/angular-mocks/angular-mocks.js',
'src/*/test/*.js',
'dist/ng-tasty.js',
'template/table/*.html.js'
'template/**/*.html.js'
])
.pipe(karma({
configFile: 'karma.conf.js',
Expand All @@ -126,7 +141,7 @@ gulp.task('full-test', function() {
'components/angular-mocks/angular-mocks.js',
'src/*/test/*.js',
'dist/ng-tasty.min.js',
'template/table/*.html.js'
'template/**/*.html.js'
])
.pipe(karma({
configFile: 'karma.conf.js',
Expand All @@ -141,7 +156,7 @@ gulp.task('full-test', function() {
'components/angular-mocks/angular-mocks.js',
'src/*/test/*.js',
'dist/ng-tasty-tpls.js',
'template/table/*.html.js'
'template/**/*.html.js'
])
.pipe(karma({
configFile: 'karma.conf.js',
Expand All @@ -156,7 +171,7 @@ gulp.task('full-test', function() {
'components/angular-mocks/angular-mocks.js',
'src/*/test/*.js',
'dist/ng-tasty-tpls.min.js',
'template/table/*.html.js'
'template/**/*.html.js'
])
.pipe(karma({
configFile: 'karma.conf.js',
Expand Down Expand Up @@ -195,40 +210,43 @@ gulp.task('watch', function() {
}));
});

var srcModules = [];
var tplModules = [];

function getExtension(filename) {
var i = filename.lastIndexOf('.');
return (i < 0) ? '' : filename.substr(i);
}

gulp.task('get-modules-name', function() {
function enquote(str) {
return '"' + str + '"';
}

fs.readdir('src/component', function (err, components) {
components = components.filter(function(component) {
return component.split('.').pop() == 'js';
var setModules = function (folder, files) {
files = files.filter(function(file) {
return file.split('.').pop() == 'js';
});
components.forEach(function (component) {
component = component.split('.')[0];
srcModules.push(enquote('ngTasty.component.' + component));
fs.readdir('template/' + component, function (err, files) {
if (!files) {
return;
}
files = files.filter(function(file) {
return getExtension(file) === '.html';
});
files.forEach(function (file) {
var module = 'ngTasty.tpls.' + capitaliseFirstLetter(component);
module += capitaliseFirstLetter(file.split('.')[0]);
tplModules.push(enquote(module));
});
});
files.forEach(function (file) {
file = file.split('.')[0];
var module = 'ngTasty.'+ camelCase(folder) + '.' + camelCase(file);
srcModules.push(enquote(module));
if (folder === 'component') {
setTplsModules(file);
}
})
};
var setTplsModules = function (component) {
fs.readdir('template/' + component, function (err, files) {
if (!files) {
return;
}
files = files.filter(function(file) {
return getExtension(file) === '.html';
});
files.forEach(function (file) {
var module = 'ngTasty.tpls.' + camelCase(component);
module += '.' + camelCase(file.split('.')[0]);
tplModules.push(enquote(module));
});
});
};
fs.readdir('src/component', function (err, files) {
setModules('component', files)
});
fs.readdir('src/filter', function (err, files) {
setModules('filter', files)
});
fs.readdir('src/service', function (err, files) {
setModules('service', files)
});
});

Expand Down
4 changes: 2 additions & 2 deletions src/component/table.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ angular.module('ngTasty.component.table', [
'ngTasty.filter.cleanFieldName',
'ngTasty.filter.range',
'ngTasty.service.tastyUtil',
'ngTasty.tpls.TableHead',
'ngTasty.tpls.TablePagination'
'ngTasty.tpls.table.head',
'ngTasty.tpls.table.pagination'
])
.constant('tableConfig', {
init: {
Expand Down
4 changes: 2 additions & 2 deletions src/component/test/table.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ describe('Directive', function () {
beforeEach(module('ngTasty.service.tastyUtil'));
beforeEach(module('ngTasty.component.table'));
beforeEach(module('mockedAPIResponse'));
beforeEach(module('ngTasty.tpls.TableHead'));
beforeEach(module('ngTasty.tpls.TablePagination'));
beforeEach(module('ngTasty.tpls.table.head'));
beforeEach(module('ngTasty.tpls.table.pagination'));


describe('ngTasty table configs', function () {
Expand Down

0 comments on commit c4cd9f3

Please sign in to comment.