showdown/Gruntfile.js

218 lines
4.9 KiB
JavaScript
Raw Normal View History

2015-01-05 05:27:45 +08:00
/**
* Created by Tivie on 12-11-2014.
*/
module.exports = function (grunt) {
if (grunt.option('q') || grunt.option('quiet')) {
require('quiet-grunt');
}
// Project configuration.
var config = {
pkg: grunt.file.readJSON('package.json'),
concat: {
options: {
sourceMap: true,
2017-08-24 05:56:30 +08:00
banner: ';/*! <%= pkg.name %> v <%= pkg.version %> - <%= grunt.template.today("dd-mm-yyyy") %> */\n(function(){\n',
footer: '}).call(this);\n'
},
dist: {
src: [
2015-07-13 12:09:03 +08:00
'src/options.js',
'src/showdown.js',
'src/helpers.js',
'src/subParsers/makehtml/*.js',
'src/subParsers/makemarkdown/*.js',
'src/converter.js',
'src/loader.js'
],
dest: 'dist/<%= pkg.name %>.js'
},
test: {
src: '<%= concat.dist.src %>',
dest: '.build/<%= pkg.name %>.js',
options: {
sourceMap: false
}
}
},
clean: ['.build/'],
uglify: {
options: {
sourceMap: true,
2017-08-24 05:56:30 +08:00
banner: '/*! <%= pkg.name %> v <%= pkg.version %> - <%= grunt.template.today("dd-mm-yyyy") %> */'
},
dist: {
files: {
'dist/<%= pkg.name %>.min.js': ['<%= concat.dist.dest %>']
2015-01-05 05:27:45 +08:00
}
}
},
endline: {
dist: {
files: {
'dist/<%= pkg.name %>.js': 'dist/<%= pkg.name %>.js',
'dist/<%= pkg.name %>.min.js': 'dist/<%= pkg.name %>.min.js'
}
}
},
jshint: {
2015-06-17 08:26:50 +08:00
options: {
2016-09-29 07:20:30 +08:00
jshintrc: '.jshintrc',
reporterOutput: ''
2015-06-17 08:26:50 +08:00
},
files: [
'Gruntfile.js',
'src/**/*.js',
'test/**/*.js'
]
},
eslint: {
options: {
config: '.eslintrc.json'
2015-04-22 23:56:31 +08:00
},
target: [
'Gruntfile.js',
'src/**/*.js',
'test/**/*.js'
]
},
conventionalChangelog: {
2015-05-14 08:59:33 +08:00
options: {
changelogOpts: {
preset: 'angular'
}
},
release: {
src: 'CHANGELOG.md'
2015-05-14 08:59:33 +08:00
}
},
conventionalGithubReleaser: {
release: {
options: {
auth: {
type: 'oauth',
token: process.env.GH_TOEKN
},
changelogOpts: {
preset: 'angular'
}
}
}
},
simplemocha: {
2017-12-22 23:28:41 +08:00
functional: {
src: 'test/functional/**/*.js',
options: {
globals: ['should'],
timeout: 3000,
2015-07-15 04:17:27 +08:00
ignoreLeaks: true,
reporter: 'spec'
}
},
2017-12-22 23:28:41 +08:00
unit: {
src: 'test/unit/**/*.js',
options: {
globals: ['should'],
timeout: 3000,
2017-12-22 23:28:41 +08:00
ignoreLeaks: true,
reporter: 'spec'
}
},
single: {
src: 'test/node/**/*.js',
options: {
globals: ['should'],
timeout: 3000,
ignoreLeaks: false,
reporter: 'spec'
}
}
}
};
grunt.initConfig(config);
2015-01-05 05:27:45 +08:00
/**
* Load common tasks for legacy and normal tests
*/
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-simple-mocha');
grunt.loadNpmTasks('grunt-endline');
grunt.loadNpmTasks('grunt-contrib-jshint');
2015-01-05 05:27:45 +08:00
/**
* Generate Changelog
*/
grunt.registerTask('generate-changelog', function () {
'use strict';
grunt.loadNpmTasks('grunt-conventional-changelog');
grunt.loadNpmTasks('grunt-conventional-github-releaser');
grunt.task.run('conventionalChangelog');
});
/**
* Lint tasks
*/
grunt.registerTask('lint', function () {
'use strict';
grunt.loadNpmTasks('grunt-eslint');
grunt.task.run('jshint', 'eslint');
});
/**
* Performance task
*/
grunt.registerTask('performancejs', function () {
'use strict';
2017-12-22 23:28:41 +08:00
var perf = require('./test/performance/performance.js');
perf.runTests();
perf.generateLogs();
});
/**
* Run a single test
*/
grunt.registerTask('single-test', function (grep) {
'use strict';
grunt.config.merge({
simplemocha: {
single: {
options: {
grep: grep
}
}
}
});
grunt.task.run(['lint', 'concat:test', 'simplemocha:single', 'clean']);
});
/**
2017-12-22 23:28:41 +08:00
* Tasks
*/
2017-12-22 23:28:41 +08:00
grunt.registerTask('test', ['clean', 'lint', 'concat:test', 'simplemocha:unit', 'simplemocha:functional', 'clean']);
grunt.registerTask('test-functional', ['concat:test', 'simplemocha:functional', 'clean']);
grunt.registerTask('test-unit', ['concat:test', 'simplemocha:unit', 'clean']);
2016-12-23 17:29:58 +08:00
grunt.registerTask('performance', ['concat:test', 'performancejs', 'clean']);
grunt.registerTask('build', ['test', 'concat:dist', 'uglify', 'endline']);
grunt.registerTask('build-without-test', ['concat:dist', 'uglify', 'endline']);
grunt.registerTask('prep-release', ['build', 'generate-changelog']);
2015-01-05 05:27:45 +08:00
// Default task(s).
2015-05-27 09:21:36 +08:00
grunt.registerTask('default', ['test']);
2015-01-05 05:27:45 +08:00
};