Skip to content

Commit

Permalink
Merge pull request #20 from JohnnyEstilles/feature/code-refactoring
Browse files Browse the repository at this point in the history
Refactoring code to improve testability
  • Loading branch information
rafinskipg committed Apr 21, 2015
2 parents 7d05b63 + 987366f commit be209f0
Show file tree
Hide file tree
Showing 20 changed files with 1,497 additions and 590 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
coverage
node_modules
npm-debug.log
tmp
CHANGELOG.md
EXTENDEDCHANGELOG.md
output
11 changes: 11 additions & 0 deletions .istanbul.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
reporting:
print: summary
reports:
- lcov
- html
dir: ./coverage
report-config:
dir: './coverage'
lcovonly: {file: lcov.info}
text: {file: null, maxCols: 0}
text-summary: {file: null}
4 changes: 3 additions & 1 deletion .jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,7 @@
"undef": true,
"boss": true,
"eqnull": true,
"node": true
"node": true,
"mocha": true,
"expr": true
}
25 changes: 22 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,26 @@
language: node_js
node_js:
- "0.10"
before_install:
- "0.12"

notifications:
email:
- "[email protected]"
- "[email protected]"

addons:
code_climate:
repo_token: b6ed20570f0ec30b5b2acdbd706593928f204693efcd634110a36bc5f94822d9

before_install:
- npm install -g grunt-cli
install:
- npm install
- npm install -g mocha
- npm install -g istanbul
- npm install -g codeclimate-test-reporter

before_script:
- grunt jshint pre-test

after_script:
- istanbul cover node_modules/.bin/_mocha -- -R dot
- codeclimate < ./coverage/lcov.info
7 changes: 0 additions & 7 deletions CHANGELOG.md

This file was deleted.

62 changes: 0 additions & 62 deletions EXTENDEDCHANGELOG.md

This file was deleted.

24 changes: 15 additions & 9 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ module.exports = function(grunt) {
jshint: {
all: [
'Gruntfile.js',
'tasks/*.js',
'<%= nodeunit.tests %>',
'tasks/**/*.js',
'test/**/*.spec.js'
],
options: {
jshintrc: '.jshintrc',
Expand All @@ -25,14 +25,17 @@ module.exports = function(grunt) {

// Before generating any new files, remove any previously-created files.
clean: {
tests: ['tmp'],
tests: [
'output/tag1.md',
'EXTENDEDCHANGELOG.md'
],
},

// Configuration to be run (and then tested).
git_changelog: {
minimal: {
options: {
appName : 'Git changelog'
app_name : 'Git changelog'
}
},
tag1: {
Expand All @@ -46,8 +49,9 @@ module.exports = function(grunt) {
extended: {
options: {
repo_url: 'https://github.com/rafinskipg/git-changelog',
appName : 'Git changelog extended',
ignore_tags: true,
app_name : 'Git changelog extended',
tag: false,
debug: true,
file : 'EXTENDEDCHANGELOG.md',
grep_commits: '^fix|^feat|^docs|^refactor|^chore|BREAKING'
}
Expand All @@ -67,7 +71,8 @@ module.exports = function(grunt) {
},
src: ['test/**/*.spec.js']
}
}
},

});

// Actually load this plugin's task(s).
Expand All @@ -80,10 +85,11 @@ module.exports = function(grunt) {

// Whenever the "test" task is run, first clean the "tmp" dir, then run this
// plugin's task(s), then test the result.
grunt.registerTask('test', ['clean', 'git_changelog', 'mochaTest']);
grunt.registerTask('pre-test', ['clean', 'git_changelog']);
// grunt.registerTask('test', ['clean', 'git_changelog', 'mochaTest']);

// By default, lint and run all tests.
grunt.registerTask('default', ['jshint', 'test']);
grunt.registerTask('default', ['jshint', 'pre-test']);

// By default, lint and run all tests.
grunt.registerTask('ch', [ 'git_changelog']);
Expand Down
17 changes: 13 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,25 @@ grunt.initConfig({
git_changelog: {
minimal: {
options: {
file: 'https://github.com/rafinskipg/git-changelog',
appName : 'Git changelog'
file: 'MyChangelog.md',
app_name : 'Git changelog'
}
},
extended: {
options: {
repo_url: 'https://github.com/rafinskipg/git-changelog',
appName : 'Git changelog extended',
app_name : 'Git changelog extended',
file : 'EXTENDEDCHANGELOG.md',
grep_commits: '^fix|^feat|^docs|^refactor|^chore|BREAKING'
grep_commits: '^fix|^feat|^docs|^refactor|^chore|BREAKING',
tag : false //False for commits since the beggining
}
},
fromCertainTag: {
options: {
repo_url: 'https://github.com/rafinskipg/git-changelog',
app_name : 'My project name',
file : 'tags/certainTag.md',
tag : 'v0.0.1'
}
}
}
Expand Down
47 changes: 0 additions & 47 deletions output/tag1.md

This file was deleted.

22 changes: 14 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,31 @@
"node": ">= 0.8.0"
},
"scripts": {
"test": "grunt test"
"pre-test": "grunt",
"test": "mocha -R spec test/**/*.spec.js",
"coverage": "istanbul cover node_modules/.bin/_mocha -- -R dot"
},
"dependencies": {
"commander": "^2.8.0",
"lodash": "^2.4.1",
"q": "~0.9.7"
"debug": "^2.1.3",
"lodash": "^3.7.0",
"q": "^1.2.0"
},
"preferGlobal": "true",
"bin": {
"git-changelog": "tasks/command.js"
},
"devDependencies": {
"chai": "^1.9.2",
"exec": "0.0.6",
"chai": "^2.2.0",
"chai-as-promised": "^5.0.0",
"grunt": "^0.4.5",
"grunt-contrib-clean": "~0.4.0",
"grunt-contrib-jshint": "~0.6.0",
"grunt-contrib-clean": "^0.6.0",
"grunt-contrib-jshint": "^0.11.2",
"grunt-mocha-test": "^0.12.1",
"mocha": "^1.21.4"
"istanbul": "^0.3.13",
"mocha": "^2.2.4",
"sinon": "^1.14.1",
"sinon-chai": "^2.7.0"
},
"peerDependencies": {
"grunt": "~0.4.1"
Expand Down
8 changes: 4 additions & 4 deletions tasks/command.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/usr/bin/env node


'use strict';

var program = require('commander');
Expand Down Expand Up @@ -48,7 +47,7 @@ if (process.argv.join('').indexOf('/grunt') === -1) {
console.log(' - With URL %s', program.url);
}

if (program.tag != undefined){
if (program.tag !== undefined){
if(program.tag === false || program.tag === "false"){
options.tag = false;
console.log(' - No tag, getting log since the BigBang');
Expand All @@ -66,6 +65,7 @@ if (process.argv.join('').indexOf('/grunt') === -1) {
console.log(' - The output file is %s', options.file);

git_changelog.generate(options).then(function(){
console.log('Finished generating log Yai!')
console.log('Finished generating log Yai!');
});
}

}
Loading

0 comments on commit be209f0

Please sign in to comment.