2015-01-05 05:27:45 +08:00
|
|
|
/**
|
|
|
|
* Created by Tivie on 12-11-2014.
|
|
|
|
*/
|
|
|
|
|
|
|
|
module.exports = function (grunt) {
|
|
|
|
|
2015-07-12 02:12:04 +08:00
|
|
|
if (grunt.option('q') || grunt.option('quiet')) {
|
|
|
|
require('quiet-grunt');
|
|
|
|
}
|
|
|
|
|
2015-01-19 23:43:47 +08:00
|
|
|
// Project configuration.
|
|
|
|
var config = {
|
|
|
|
pkg: grunt.file.readJSON('package.json'),
|
2015-06-01 01:45:33 +08:00
|
|
|
|
2015-01-19 23:43:47 +08:00
|
|
|
concat: {
|
|
|
|
options: {
|
|
|
|
sourceMap: true,
|
|
|
|
banner: ';/*! <%= pkg.name %> <%= grunt.template.today("dd-mm-yyyy") %> */\n(function(){\n',
|
2015-05-28 19:50:57 +08:00
|
|
|
footer: '}).call(this);'
|
2015-01-19 23:43:47 +08:00
|
|
|
},
|
|
|
|
dist: {
|
2015-07-11 04:00:21 +08:00
|
|
|
src: [
|
2015-01-19 23:43:47 +08:00
|
|
|
'src/showdown.js',
|
|
|
|
'src/helpers.js',
|
2015-06-01 03:56:28 +08:00
|
|
|
'src/converter.js',
|
2015-01-19 23:43:47 +08:00
|
|
|
'src/subParsers/*.js',
|
|
|
|
'src/loader.js'
|
|
|
|
],
|
|
|
|
dest: 'dist/<%= pkg.name %>.js'
|
2015-07-11 04:00:21 +08:00
|
|
|
},
|
|
|
|
test: {
|
2015-07-12 02:32:22 +08:00
|
|
|
src: '<%= concat.dist.src %>',
|
2015-07-11 04:00:21 +08:00
|
|
|
dest: '.build/<%= pkg.name %>.js',
|
|
|
|
options: {
|
|
|
|
sourceMap: false
|
|
|
|
}
|
2015-01-19 23:43:47 +08:00
|
|
|
}
|
|
|
|
},
|
2015-06-01 03:56:28 +08:00
|
|
|
|
2015-07-11 04:00:21 +08:00
|
|
|
clean: ['.build/'],
|
|
|
|
|
2015-01-19 23:43:47 +08:00
|
|
|
uglify: {
|
|
|
|
options: {
|
|
|
|
sourceMap: true,
|
|
|
|
banner: '/*! <%= pkg.name %> <%= grunt.template.today("dd-mm-yyyy") %> */\n'
|
|
|
|
},
|
|
|
|
dist: {
|
|
|
|
files: {
|
|
|
|
'dist/<%= pkg.name %>.min.js': ['<%= concat.dist.dest %>']
|
2015-01-05 05:27:45 +08:00
|
|
|
}
|
2015-01-19 23:43:47 +08:00
|
|
|
}
|
|
|
|
},
|
2015-06-01 01:45:33 +08:00
|
|
|
|
2015-01-19 23:43:47 +08:00
|
|
|
jshint: {
|
2015-06-17 08:26:50 +08:00
|
|
|
options: {
|
|
|
|
jshintrc: '.jshintrc'
|
|
|
|
},
|
2015-01-19 23:43:47 +08:00
|
|
|
files: [
|
|
|
|
'Gruntfile.js',
|
|
|
|
'src/**/*.js',
|
|
|
|
'test/**/*.js'
|
|
|
|
]
|
|
|
|
},
|
2015-06-01 01:45:33 +08:00
|
|
|
|
2015-01-19 23:43:47 +08:00
|
|
|
jscs: {
|
|
|
|
options: {
|
2015-06-01 01:45:33 +08:00
|
|
|
config: '.jscs.json'
|
2015-04-22 23:56:31 +08:00
|
|
|
},
|
2015-07-11 04:00:21 +08:00
|
|
|
files: {
|
2015-04-22 23:56:31 +08:00
|
|
|
src: [
|
2015-01-19 23:43:47 +08:00
|
|
|
'Gruntfile.js',
|
|
|
|
'src/**/*.js',
|
|
|
|
'test/**/*.js'
|
|
|
|
]
|
|
|
|
}
|
|
|
|
},
|
2015-06-01 01:45:33 +08:00
|
|
|
|
2015-01-20 00:27:28 +08:00
|
|
|
changelog: {
|
2015-05-14 08:59:33 +08:00
|
|
|
options: {
|
|
|
|
repository: 'http://github.com/showdownjs/showdown',
|
|
|
|
dest: 'CHANGELOG.md'
|
|
|
|
}
|
2015-01-20 00:27:28 +08:00
|
|
|
},
|
2015-06-01 01:45:33 +08:00
|
|
|
|
2015-01-19 23:43:47 +08:00
|
|
|
simplemocha: {
|
|
|
|
node: {
|
|
|
|
src: 'test/node/**/*.js',
|
|
|
|
options: {
|
|
|
|
globals: ['should'],
|
|
|
|
timeout: 3000,
|
|
|
|
ignoreLeaks: false,
|
|
|
|
reporter: 'spec'
|
|
|
|
}
|
|
|
|
},
|
2015-06-11 08:29:42 +08:00
|
|
|
karlcow: {
|
|
|
|
src: 'test/node/testsuite.karlcow.js',
|
|
|
|
options: {
|
|
|
|
globals: ['should'],
|
|
|
|
timeout: 3000,
|
|
|
|
ignoreLeaks: false,
|
|
|
|
reporter: 'spec'
|
2015-07-11 09:42:53 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
issues: {
|
|
|
|
src: 'test/node/testsuite.issues.js',
|
|
|
|
options: {
|
|
|
|
globals: ['should'],
|
|
|
|
timeout: 3000,
|
|
|
|
ignoreLeaks: false,
|
|
|
|
reporter: 'spec'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
standard: {
|
|
|
|
src: 'test/node/testsuite.standard.js',
|
|
|
|
options: {
|
|
|
|
globals: ['should'],
|
|
|
|
timeout: 3000,
|
|
|
|
ignoreLeaks: false,
|
|
|
|
reporter: 'spec'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
features: {
|
|
|
|
src: 'test/node/testsuite.features.js',
|
|
|
|
options: {
|
|
|
|
globals: ['should'],
|
|
|
|
timeout: 3000,
|
|
|
|
ignoreLeaks: false,
|
|
|
|
reporter: 'spec'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
single: {
|
|
|
|
src: 'test/node/**/*.js',
|
|
|
|
options: {
|
|
|
|
globals: ['should'],
|
|
|
|
timeout: 3000,
|
|
|
|
ignoreLeaks: false,
|
|
|
|
reporter: 'spec'
|
2015-01-19 23:43:47 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
grunt.initConfig(config);
|
2015-01-05 05:27:45 +08:00
|
|
|
|
2015-06-01 01:45:33 +08:00
|
|
|
require('load-grunt-tasks')(grunt);
|
2015-01-05 05:27:45 +08:00
|
|
|
|
2015-07-11 09:42:53 +08:00
|
|
|
grunt.registerTask('single-test', function (grep) {
|
|
|
|
'use strict';
|
|
|
|
grunt.config.merge({
|
|
|
|
simplemocha: {
|
|
|
|
single: {
|
|
|
|
options: {
|
|
|
|
grep: grep
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2015-07-12 02:41:31 +08:00
|
|
|
grunt.task.run(['lint', 'concat:test', 'simplemocha:single', 'clean']);
|
2015-07-11 09:42:53 +08:00
|
|
|
});
|
|
|
|
|
2015-01-19 23:43:47 +08:00
|
|
|
grunt.registerTask('lint', ['jshint', 'jscs']);
|
2015-07-12 02:32:22 +08:00
|
|
|
grunt.registerTask('test', ['clean', 'lint', 'concat:test', 'simplemocha:node', 'clean']);
|
2015-07-12 02:47:57 +08:00
|
|
|
grunt.registerTask('build', ['test', 'concat:dist', 'uglify']);
|
2015-05-23 09:07:19 +08:00
|
|
|
grunt.registerTask('prep-release', ['build', 'changelog']);
|
2015-01-05 05:27:45 +08:00
|
|
|
|
2015-01-19 23:43:47 +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
|
|
|
};
|