forked from jsdoc/jsdoc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
abolish the post-install script and template/plugin copying (jsdoc#519,
jsdoc#612) JSDoc has a few requirements that are somewhat unusual for a Node.js app: 1. We need `require('jsdoc/foo')` to work from any module. 2. We need `require('jsdoc/foo')` to work from external code, such as templates and plugins. Prior to this commit, JSDoc did two separate things to meet these requirements: 1. Use an npm post-install script to create a symlink from `lib/jsdoc` to `node_modules/jsdoc`. 2. When a user runs JSDoc, copy templates and plugins into the JSDoc directory. These fixes worked, sort of. But they also caused numerous issues with file permissions, especially on Windows. We now use the Requizzle module, which hacks the Node.js module system to support JSDoc's use cases. There's no longer a post-install script, and there's no need for a symlink in `node_modules`.
- Loading branch information
Showing
15 changed files
with
612 additions
and
173 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
#!/usr/bin/env node | ||
/*global arguments */ | ||
/*global arguments, require: true */ | ||
/** | ||
* @project jsdoc | ||
* @author Michael Mathews <[email protected]> | ||
|
@@ -86,12 +86,23 @@ global.env = { | |
(function(args) { | ||
'use strict'; | ||
|
||
var path; | ||
|
||
if (args[0] && typeof args[0] === 'object') { | ||
// we should be on Node.js | ||
args = [__dirname, process.cwd()]; | ||
path = require('path'); | ||
|
||
// Create a custom require method that adds `lib/jsdoc` to the module lookup path. | ||
// This makes it possible to `require('jsdoc/foo')` from external templates and plugins, | ||
// and within JSDoc itself. | ||
require = require('requizzle')({ | ||
requirePaths: [path.join(__dirname, 'lib')], | ||
infect: true | ||
}); | ||
} | ||
|
||
require('jsdoc/util/runtime').initialize(args); | ||
require('./lib/jsdoc/util/runtime').initialize(args); | ||
})( Array.prototype.slice.call(arguments, 0) ); | ||
|
||
/** | ||
|
@@ -102,9 +113,9 @@ global.env = { | |
*/ | ||
global.app = { | ||
jsdoc: { | ||
scanner: new (require('jsdoc/src/scanner').Scanner)(), | ||
name: require('./lib/jsdoc/name'), | ||
parser: null, | ||
name: require('jsdoc/name') | ||
scanner: new (require('./lib/jsdoc/src/scanner').Scanner)() | ||
} | ||
}; | ||
|
||
|
@@ -121,8 +132,8 @@ global.app = { | |
global.dump = function() { | ||
'use strict'; | ||
|
||
var doop = require('jsdoc/util/doop').doop; | ||
var _dump = require('jsdoc/util/dumper').dump; | ||
var doop = require('./lib/jsdoc/util/doop').doop; | ||
var _dump = require('./lib/jsdoc/util/dumper').dump; | ||
for (var i = 0, l = arguments.length; i < l; i++) { | ||
console.log( _dump(doop(arguments[i])) ); | ||
} | ||
|
@@ -131,11 +142,14 @@ global.dump = function() { | |
(function() { | ||
'use strict'; | ||
|
||
var logger = require('jsdoc/util/logger'); | ||
var path = require('jsdoc/path'); | ||
var runtime = require('jsdoc/util/runtime'); | ||
var logger = require('./lib/jsdoc/util/logger'); | ||
var runtime = require('./lib/jsdoc/util/runtime'); | ||
var cli = require('./cli'); | ||
|
||
var cli = require( path.join(global.env.dirname, 'cli') ); | ||
function cb(errorCode) { | ||
cli.logFinish(); | ||
cli.exit(errorCode || 0); | ||
} | ||
|
||
cli.setVersionInfo() | ||
.loadConfig(); | ||
|
@@ -146,11 +160,6 @@ global.dump = function() { | |
|
||
cli.logStart(); | ||
|
||
function cb(errorCode) { | ||
cli.logFinish(); | ||
cli.exit(errorCode || 0); | ||
} | ||
|
||
// On Rhino, we use a try/catch block so we can log the Java exception (if available) | ||
if ( runtime.isRhino() ) { | ||
try { | ||
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.