Skip to content

Commit

Permalink
fix(cli): fix cli to work with yargs
Browse files Browse the repository at this point in the history
Related to #893
  • Loading branch information
tivie committed Mar 7, 2022
1 parent b3dd26a commit f8c4bd2
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 9 deletions.
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.

2 changes: 1 addition & 1 deletion 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.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package-lock.json

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

11 changes: 7 additions & 4 deletions src/cli/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,22 @@
* Created by tivie
*/
var fs = require('fs'),
path = require('path'),
json = JSON.parse(fs.readFileSync('package.json', 'utf8')),
version = json.version,
Command = require('commander').Command,
program = new Command(),
path1 = path.resolve(__dirname + '/../dist/showdown.js'),
path2 = path.resolve(__dirname + '/../../.build/showdown.js'),
showdown;

// require shodown. We use conditional loading for each use case
if (fs.existsSync('../dist/showdown.js')) {
if (fs.existsSync(path1)) {
// production. File lives in bin directory
showdown = require('../dist/showdown');
} else if (fs.existsSync('../../.build/showdown.js')) {
showdown = require(path1);
} else if (fs.existsSync(path2)) {
// testing envo, uses the concatenated stuff for testing
showdown = require('../../.build/showdown.js');
showdown = require(path2);
} else {
// cold testing (manual) of cli.js in the src file. We load the dist file
showdown = require('../../dist/showdown');
Expand Down

0 comments on commit f8c4bd2

Please sign in to comment.