Skip to content

Commit

Permalink
fix(cli): cli now works properly
Browse files Browse the repository at this point in the history
The CLI was completely rewrote. Changed dependency from yargs to commanderjs,
which is cleaner, faster and has no dependencies.
Also added a complete testsuite for the cli.

Closes #893, #894
  • Loading branch information
tivie committed Mar 3, 2022
1 parent 612dad0 commit 3871765
Show file tree
Hide file tree
Showing 24 changed files with 926 additions and 501 deletions.
53 changes: 36 additions & 17 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ module.exports = function (grunt) {
pkg: grunt.file.readJSON('package.json'),

concat: {
options: {
sourceMap: true,
banner: ';/*! <%= pkg.name %> v <%= pkg.version %> - <%= grunt.template.today("dd-mm-yyyy") %> */\n(function(){\n',
footer: '}).call(this);\n'
},
dist: {
options: {
sourceMap: true,
banner: ';/*! <%= pkg.name %> v <%= pkg.version %> - <%= grunt.template.today("dd-mm-yyyy") %> */\n(function(){\n',
footer: '}).call(this);\n'
},
src: [
'src/options.js',
'src/showdown.js',
Expand All @@ -30,6 +30,12 @@ module.exports = function (grunt) {
],
dest: 'dist/<%= pkg.name %>.js'
},
cli: {
src: [
'src/cli/cli.js'
],
dest: 'bin/showdown.js'
},
test: {
src: '<%= concat.dist.src %>',
dest: '.build/<%= pkg.name %>.js',
Expand All @@ -42,14 +48,23 @@ module.exports = function (grunt) {
clean: ['.build/'],

uglify: {
options: {
sourceMap: true,
banner: '/*! <%= pkg.name %> v <%= pkg.version %> - <%= grunt.template.today("dd-mm-yyyy") %> */'
},
dist: {
options: {
sourceMap: true,
banner: '/*! <%= pkg.name %> v <%= pkg.version %> - <%= grunt.template.today("dd-mm-yyyy") %> */'
},
files: {
'dist/<%= pkg.name %>.min.js': ['<%= concat.dist.dest %>']
}
},
cli: {
options: {
sourceMap: false,
banner: '#!/usr/bin/env node'
},
files: {
'bin/showdown.js': ['<%= concat.cli.dest %>']
}
}
},

Expand Down Expand Up @@ -164,6 +179,15 @@ module.exports = function (grunt) {
ignoreLeaks: false,
reporter: 'spec'
}
},
cli: {
src: 'test/node/testsuite.cli.js',
options: {
globals: ['should'],
timeout: 3000,
ignoreLeaks: false,
reporter: 'spec'
}
}
}
};
Expand Down Expand Up @@ -227,19 +251,14 @@ module.exports = function (grunt) {
grunt.task.run(['lint', 'concat:test', 'simplemocha:single', 'clean']);
});


/**
* Test in Legacy Node
*/
grunt.registerTask('test-old', ['concat:test', 'simplemocha:node', 'clean']);

/**
* Tasks for new node versions
*/
grunt.registerTask('test', ['clean', 'lint', 'concat:test', 'simplemocha:node', 'clean']);
grunt.registerTask('test-cli', ['clean', 'lint', 'concat:test', 'simplemocha:cli', 'clean']);
grunt.registerTask('performance', ['concat:test', 'performancejs', 'clean']);
grunt.registerTask('build', ['test', 'concat:dist', 'uglify', 'endline']);
grunt.registerTask('prep-release', ['build', 'generate-changelog']);
grunt.registerTask('build', ['test', 'concat:dist', 'concat:cli', 'uglify:dist', 'uglify:cli', 'endline']);
grunt.registerTask('prep-release', ['build', 'performance', 'generate-changelog']);

// Default task(s).
grunt.registerTask('default', ['test']);
Expand Down
2 changes: 1 addition & 1 deletion bin/showdown.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 17 additions & 17 deletions dist/showdown.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/showdown.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/showdown.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/showdown.min.js.map

Large diffs are not rendered by default.

Loading

0 comments on commit 3871765

Please sign in to comment.