Skip to content

Commit

Permalink
Fixed a couple bugs.
Browse files Browse the repository at this point in the history
  • Loading branch information
skrenek committed Apr 19, 2011
1 parent 7168aa8 commit a3c09fc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 18 deletions.
4 changes: 2 additions & 2 deletions app/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ function main() {
}
else {
// a template must be defined and must be a directory path
if (!JSDOC.opt.t && System.getProperty("jsdoc.template.dir")) {
JSDOC.opt.t = System.getProperty("jsdoc.template.dir");
if (!JSDOC.opt.t && process.env.JSDOCTEMPLATEDIR) {
JSDOC.opt.t = process.env.JSDOCTEMPLATEDIR;
}
if (JSDOC.opt.t && SYS.slash != JSDOC.opt.t.slice(-1)) {
JSDOC.opt.t += SYS.slash;
Expand Down
29 changes: 13 additions & 16 deletions app/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@

// load the node.js libraries to be abstracted
var fs = require('fs');
var path = require('path');
var Script = process.binding('evals').Script;

// define a few globals to be compatible with jsrun.jar
global.arguments = process.argv.slice(2);
global.arguments = global.internal_args || process.argv.slice(2);
load = function(file) {
Script.runInThisContext(fs.readFileSync(file), file);
};
Expand Down Expand Up @@ -48,11 +49,11 @@ LOG.out = undefined;
* @class Manipulate a filepath.
*/
FilePath = function(absPath, separator) {
this.slash = separator || "/";
this.slash = separator || "/";
this.root = this.slash;
this.path = [];
this.file = "";

var parts = absPath.split(/[\\\/]/);
if (parts) {
if (parts.length) this.root = parts.shift() + this.slash;
Expand Down Expand Up @@ -159,18 +160,14 @@ IO = {
*/
copyFile: function(/**string*/ inFile, /**string*/ outDir, /**string*/ fileName) {
if (fileName == null) fileName = FilePath.fileName(inFile);

var inFile = fs.openSync(inFile, "r");
var outFile = fs.openSync(outDir+"/"+fileName, "w");

var buf = new Buffer(4096);

while (fs.readSync(inFile, buf, 0, buf.length) > 0) {
fs.writeSync(outFile, buf);
}

fs.closeSync(inFile);
fs.closeSync(outFile);
inFile = path.normalize(inFile);
outFile = path.normalize(outDir + "/" + fileName);
if (!path.existsSync(inFile)) {
// Could not find file to copy, ignoring: ' + inFile
// Should we log or safe to ignore?
return;
};
fs.createReadStream(inFile).pipe(fs.createWriteStream(outFile));
},

/**
Expand Down Expand Up @@ -285,7 +282,7 @@ IO = {
includeDir: function(path) {
if (!path) return;

for (var lib = IO.ls(SYS.pwd+path), i = 0; i < lib.length; i++)
for (var lib = IO.ls(SYS.pwd+path), i = 0; i < lib.length; i++)
if (/\.js$/i.test(lib[i])) load(lib[i]);
}
}
Expand Down

0 comments on commit a3c09fc

Please sign in to comment.