Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version cli fix #16

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,6 @@
.idea/watcherTasks.xml

.idea/workspace.xml

# Exported modules
/node_modules/*
26 changes: 12 additions & 14 deletions src/TSDoc.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
///<reference path="../dec/Node.d.ts"/>
///<reference path="../dec/node.d.ts"/>
var path = require('path');
var TSDdoc = (function () {
function TSDdoc() {
}
TSDdoc.cmd = function () {
var argv = require('optimist').argv;
var fs = require('fs');

var sys = require('sys');
var sys = require('util');
var exec = require('child_process').exec;
var configFile = process.cwd() + path.sep + 'tsdoc.json';
var readmeFile = process.cwd() + path.sep + 'readme.md';
var configContents = fs.readFileSync(path.resolve(__dirname, '..' + path.sep + 'template' + path.sep + 'tsdoc.json'), 'utf8');
var nodePackage = require('./../package.json');
console.log('TSDOC v' + nodePackage.version);

if (argv.i || argv.install) {
var parentDir = path.resolve(process.cwd(), '..' + path.sep);
var templateDir = path.resolve(__dirname, '..' + path.sep + 'template');
Expand All @@ -24,11 +20,15 @@ var TSDdoc = (function () {
outConfig = outConfig.replace(/\$USERNAME\$/gi, TSDdoc.getUserName());
outConfig = outConfig.replace(/\$YEAR\$/gi, new Date().getFullYear());
outConfig = outConfig.replace(/\$PROJECTNAME\$/gi, TSDdoc.processPath(process.cwd().substr(process.cwd().lastIndexOf(path.sep) + 1)));

fs.writeFileSync(configFile, outConfig, 'utf8');
console.log('TSDoc tsdoc.json generated.');
return;
} else {
}
else if (argv.v || argv.version) {
var nodePackage = require('./../package.json');
console.log('TSDOC v' + nodePackage.version);
}
else {
if (fs.existsSync(configFile)) {
console.log('TSDoc Generating doc...');
var configJson = require(configFile);
Expand All @@ -47,7 +47,8 @@ var TSDdoc = (function () {
readme
].join('');
exec(jsonParams, TSDdoc.onJSDoc);
} else {
}
else {
console.log('No tsdoc.json found, please use -i to generate one');
}
}
Expand All @@ -64,7 +65,6 @@ var TSDdoc = (function () {
var userName = (process.env.HOME || process.env.HOMEPATH || process.env.USERPROFILE);
return userName.substr(userName.lastIndexOf(path.sep) + 1);
};

TSDdoc.getReadmeFile = function () {
var fs = require('fs');
var files = fs.readdirSync(process.cwd());
Expand All @@ -76,14 +76,12 @@ var TSDdoc = (function () {
}
return readme;
};

TSDdoc.processPath = function (path) {
path = path.indexOf(':') != -1 ? path.split(':')[1] : path;
path = path.replace(/\\/gi, '/');
return path;
};
TSDdoc.nodePackage = require('./../package.json');
return TSDdoc;
})();
}());
TSDdoc.nodePackage = require('./../package.json');
(module).exports = TSDdoc;
//# sourceMappingURL=TSDoc.js.map
10 changes: 6 additions & 4 deletions src/TSDoc.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
///<reference path="../dec/Node.d.ts"/>
///<reference path="../dec/node.d.ts"/>
var path = require('path');
class TSDdoc
{
Expand All @@ -9,13 +9,11 @@ class TSDdoc
var argv = require('optimist').argv;
var fs = require('fs');

var sys = require('sys')
var sys = require('util')
var exec = require('child_process').exec;
var configFile = process.cwd()+path.sep+'tsdoc.json';
var readmeFile = process.cwd()+path.sep+'readme.md';
var configContents = fs.readFileSync(path.resolve( __dirname, '..'+path.sep+'template'+path.sep+'tsdoc.json'),'utf8');
var nodePackage = require( './../package.json' );
console.log( 'TSDOC v'+nodePackage.version );

if( argv.i || argv.install )
{
Expand All @@ -33,6 +31,10 @@ class TSDdoc
console.log('TSDoc tsdoc.json generated.');
return;
}
else if (argv.v ||argv.version){
var nodePackage = require( './../package.json' );
console.log( 'TSDOC v'+nodePackage.version );
}
else
{
if( fs.existsSync( configFile ) )
Expand Down