fix(cli): fix cli to work with yargs

Related to #893
This commit is contained in:
Estevao Soares dos Santos 2022-03-07 19:24:08 +00:00
parent b3dd26a3a5
commit f8c4bd26fc
5 changed files with 9 additions and 6 deletions

Binary file not shown.

BIN
dist/showdown.js vendored

Binary file not shown.

BIN
dist/showdown.min.js vendored

Binary file not shown.

4
package-lock.json generated
View File

@ -1,12 +1,12 @@
{ {
"name": "showdown", "name": "showdown",
"version": "2.0.1", "version": "2.0.2",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "showdown", "name": "showdown",
"version": "2.0.1", "version": "2.0.2",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"commander": "^9.0.0" "commander": "^9.0.0"

View File

@ -2,19 +2,22 @@
* Created by tivie * Created by tivie
*/ */
var fs = require('fs'), var fs = require('fs'),
path = require('path'),
json = JSON.parse(fs.readFileSync('package.json', 'utf8')), json = JSON.parse(fs.readFileSync('package.json', 'utf8')),
version = json.version, version = json.version,
Command = require('commander').Command, Command = require('commander').Command,
program = new Command(), program = new Command(),
path1 = path.resolve(__dirname + '/../dist/showdown.js'),
path2 = path.resolve(__dirname + '/../../.build/showdown.js'),
showdown; showdown;
// require shodown. We use conditional loading for each use case // 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 // production. File lives in bin directory
showdown = require('../dist/showdown'); showdown = require(path1);
} else if (fs.existsSync('../../.build/showdown.js')) { } else if (fs.existsSync(path2)) {
// testing envo, uses the concatenated stuff for testing // testing envo, uses the concatenated stuff for testing
showdown = require('../../.build/showdown.js'); showdown = require(path2);
} else { } else {
// cold testing (manual) of cli.js in the src file. We load the dist file // cold testing (manual) of cli.js in the src file. We load the dist file
showdown = require('../../dist/showdown'); showdown = require('../../dist/showdown');